Shoutbox

Ping? Pong! Plugin - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Forum: Plug-Ins (/forumdisplay.php?fid=28)
+------ Thread: Ping? Pong! Plugin (/showthread.php?tid=12472)

Ping? Pong! Plugin by segosa on 07-07-2003 at 01:23 PM

Thanks to patchou for the Idea :P

I changed the one in patchous sample so it would only send Ping? and not Pong! each time, and the other person would send Ping or pong accordingly, The 2 people have to have it, and it can be used to check ping time (for now you'll have to count the seconds yourself)

For example you send

/xping

(Ping? will appear on screen)

if the other person has the plugin he sends

Pong!

automatically.:)

I know this is kind of a useless plugin but i think its fun because you can actually measure the response time (as i said, in your head, for now) I will try and add a timer in so that it says the response time automatically :)


RE: Ping? Pong! Plugin by musicalmidget on 07-07-2003 at 01:42 PM

Excellent!  I like it. :D


RE: Ping? Pong! Plugin by user2319 on 07-07-2003 at 02:44 PM

* user2319 waits for the time :gfdrin:


RE: Ping? Pong! Plugin by user2319 on 07-07-2003 at 03:06 PM

He says he's concentrating.. :-/

"Segosa zegt:
challenges are possible :tongue:
Segosa zegt:
let me concentrate for a min"

btw 'zegt' is the same as 'says' :tongue:


RE: Ping? Pong! Plugin by segosa on 07-07-2003 at 03:12 PM

Yeah and its impossible on my own:( maybe with patchous help.. but i've tried and .. doesnt look bright, i know patchou could though.


RE: Ping? Pong! Plugin by trax on 07-07-2003 at 03:33 PM

is it opensource??

so people can add the time maybe


RE: RE: Ping? Pong! Plugin by user2319 on 07-07-2003 at 03:38 PM

quote:
Originally posted by trax
is it opensource??

so people can add the time maybe


he said it won't work :dodgy:
RE: Ping? Pong! Plugin by segosa on 07-07-2003 at 03:45 PM

Yeah and im not releasing the source so someone can modify my code and take the credit *cough* Sorry Patchou * cough* hehe:p ¬_¬


RE: Ping? Pong! Plugin by user2319 on 07-07-2003 at 03:53 PM

hehe.. make it gpl then :gfdrin:


RE: Ping? Pong! Plugin by trax on 07-07-2003 at 04:49 PM

I don't know if this works..
You can make the the /ping command send a time..
or thisplay it..
for example:
person1
sends the ping,
Ping: 18:48:45
Person2
sends the pong
Pong: 18:48:43

if u can make a variable like "time"
and let it act likr
Person2time - person1time = "totaltime"

I REALLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLY don't know if it works


RE: RE: Ping? Pong! Plugin by segosa on 07-07-2003 at 05:56 PM

quote:
Originally posted by trax
I don't know if this works..
You can make the the /ping command send a time..
or thisplay it..
for example:
person1
sends the ping,
Ping: 18:48:45
Person2
sends the pong
Pong: 18:48:43

if u can make a variable like "time"
and let it act likr
Person2time - person1time = "totaltime"

I REALLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLY don't know if it works


I've tried that mutliple times but even though sometimes it seems possible. it isnt :(
RE: Ping? Pong! Plugin by trax on 07-07-2003 at 06:01 PM

ahh ok

seems like a nice idea though


RE: RE: RE: Ping? Pong! Plugin by Finn on 07-07-2003 at 07:21 PM

quote:
Originally posted by segosa
quote:
Originally posted by trax
I don't know if this works..
You can make the the /ping command send a time..
or thisplay it..
for example:
person1
sends the ping,
Ping: 18:48:45
Person2
sends the pong
Pong: 18:48:43

if u can make a variable like "time"
and let it act likr
Person2time - person1time = "totaltime"

I REALLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLY don't know if it works


I've tried that mutliple times but even though sometimes it seems possible. it isnt :(


you mean like this? ;)


//////////////////////////////////////////////////////////////////////
//                                                                    //
// Project: Messenger Plus! simple plugin in language C                //
// Author: Patchou                                                    //
// Last Update: 2003/07/02                                            //
//                                                                    //
// For more help, please read the documentation in MPPluginHeader.h //
//                                                                    //
//////////////////////////////////////////////////////////////////////

#include "MPPluginC.h"
#include <stdio.h>
#include <time.h>

//////////////////////////////////////////////////////////////////////
//                                                                    //
// Purpose: DLL Entry Point                                            //
//                                                                    //
//////////////////////////////////////////////////////////////////////
BOOL APIENTRY DllMain(HANDLE hModule, DWORD nReason, void* pReserved)
{
    return TRUE;
}


//////////////////////////////////////////////////////////////////////
//                                                                    //
// Purpose: Initialization function                                    //
//                                                                    //
//////////////////////////////////////////////////////////////////////
MPPLUGIN_RETURN_BOOL Initialize(/*[in]*/ DWORD nVersion,
                                /*[in]*/ const char* sUserEmail,
                                /*[in]*/ IDispatch* iMessengerObj)
{
    return TRUE;
}


//////////////////////////////////////////////////////////////////////
//                                                                    //
// Purpose: Uninitialization function                                //
//                                                                    //
//////////////////////////////////////////////////////////////////////
MPPLUGIN_RETURN_VOID Uninitialize()
{
}

char * ConvertHex(char *string, unsigned int *Val)
{
    int len = 8;
    int ret = 0;

    while (*string && len > 0)
    {
        int toups = toupper(*(string++));

        if (toups >= '0' && toups <= '9')
        {
            ret<<=4;
            ret += toups - '0';
        } else if (toups >= 'A' && toups <= 'F') {
            ret<<=4;
            ret += (toups - 'A') + 10;
        }
        len--;
    }
    *Val = ret;
    return string;

}


char *WriteHex(char *Buf, unsigned int dw)
{
    static char* Hex = "0123456789ABCDEF";

    *(Buf++) = Hex[(dw>>28)&0xF];
    dw<<=4;
    *(Buf++) = Hex[(dw>>28)&0xF];
    dw<<=4;
    *(Buf++) = Hex[(dw>>28)&0xF];
    dw<<=4;
    *(Buf++) = Hex[(dw>>28)&0xF];
    dw<<=4;
    *(Buf++) = Hex[(dw>>28)&0xF];
    dw<<=4;
    *(Buf++) = Hex[(dw>>28)&0xF];
    dw<<=4;
    *(Buf++) = Hex[(dw>>28)&0xF];
    dw<<=4;
    *(Buf++) = Hex[(dw>>28)&0xF];
    dw<<=4;

    return Buf;
}

int bDisablePING;
int bDisablePONG;
//////////////////////////////////////////////////////////////////////
//                                                                    //
// Purpose: Provide new commands in Messenger Plus!                    //
//                                                                    //
//////////////////////////////////////////////////////////////////////
MPPLUGIN_RETURN_BOOL ParseCommand(/*[in]*/  const char* sCommand,
                                  /*[in]*/  const char* sCommandArg,
                                  /*[in]*/  PLUGIN_PARAM* pParam,
                                  /*[out]*/ char* sResult)
{
    //The first sample command displays a hello box and cancels the
    //message
    if(stricmp(sCommand, "/xping") == 0)
    {
        *(sResult++) = *sCCNotify;
        strcpy(sResult, "PING!"); //The notify code must be 5 characters long
        sResult+= 5;
        sResult = WriteHex(sResult, clock());
        strcpy(sResult, " Ping Request");
        bDisablePING = TRUE;
        return TRUE;
    }
    return FALSE;
}


//////////////////////////////////////////////////////////////////////
//                                                                    //
// Purpose: Provide new tags in Messenger Plus!                        //
//                                                                    //
//////////////////////////////////////////////////////////////////////
MPPLUGIN_RETURN_BOOL ParseTag(/*[in]*/  const char* sTag,
                              /*[in]*/  PLUGIN_PARAM* pParam,
                              /*[out]*/ char* sResult)
{

    return FALSE;
}


//static char buf[4096];

DWORD WINAPI ShowResult( void *Param)
{
    unsigned int MSTaken = (unsigned int)Param;
    char buf[200];
    wsprintf((char*)buf, "Ping Result was %4dMS", MSTaken);
    MessageBox(NULL, buf, "PONG!", MB_OK);
    return 1;
}

//////////////////////////////////////////////////////////////////////
//                                                                    //
// Purpose: Allow special actions when a plugin text is received    //
//                                                                    //
//////////////////////////////////////////////////////////////////////
MPPLUGIN_RETURN_BOOL ReceiveNotify(/*[in]*/  const char* sNotifyCode,
                                   /*[in]*/  const char* sText,
                                   /*[in]*/  PLUGIN_PARAM* pParam,
                                   /*[out]*/ char* sTextToSend)
{
    if(strcmp(sNotifyCode, "PING!") == 0 && strlen(sText) > 7)
    {
        if (!bDisablePING) {
            *(sTextToSend++) = *sCCNotify;
            strcpy(sTextToSend, "PONG!"); //The notify code must be 5 characters long
            sTextToSend += 5;
            strncpy(sTextToSend, sText, 8);
            sTextToSend += 8;
            strcpy(sTextToSend, " Ping Reply");
            bDisablePONG = TRUE;
        }
        bDisablePING = FALSE;
        return TRUE;
    }
    if(strcmp(sNotifyCode, "PONG!") == 0 && strlen(sText) > 7)
    {
        if (!bDisablePONG) {
            DWORD ID;
            clock_t StartTime;
            ConvertHex((char*)sText, (unsigned int*)&StartTime);
            StartTime = ((clock() - StartTime) * 1000) / CLOCKS_PER_SEC;
            CloseHandle(CreateThread(NULL, 0, ShowResult, (void*)StartTime, 0, &ID));
        }
        bDisablePONG = FALSE;
        return TRUE;

    }
    return FALSE;

    return FALSE;
}



RE: Ping? Pong! Plugin by surfichris on 07-08-2003 at 01:46 AM

I have nearly done one with times, just need to test it now.


RE: Ping? Pong! Plugin by BooGhost on 07-08-2003 at 01:49 AM

i'd love being a beta tester :P


RE: Ping? Pong! Plugin by segosa on 07-08-2003 at 06:11 AM

I've finished mine which says the time!!!


RE: Ping? Pong! Plugin by trax on 07-08-2003 at 06:26 AM

So what was the solution?


RE: Ping? Pong! Plugin by segosa on 07-08-2003 at 06:43 AM

http://shoutbox.menthix.net/showthread.php?tid=12546 have a look there