1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
#include <RakNetworkFactory.h>
#include <RakClientInterface.h>
#include <bitstream.h>
#include <windows.h>
#include <commctrl.h>
#include "resource.h"
RakClientInterface *client;
Packet * packet = NULL;
const unsigned char PACKET_ID_LOGIN = 100;
const unsigned char PACKET_ID_LOGINRESPONSE = 101;
const unsigned char PACKET_ID_LOGOUT = 102;
HWND hWnd;
bool loggedin = false;
bool connected = false;
bool lastconnected = false;
DWORD lasttime = 0;
void HandlePacket(RakClientInterface * client, Packet * p)
{
unsigned char packetID;
BitStream dataStream((const char*)p->data, p->length, false);
dataStream.Read(packetID);
switch(packetID) {
case PACKET_ID_LOGINRESPONSE:
dataStream.Read(loggedin);
if(!loggedin)
MessageBox(hWnd, "Incorrect Username/Password combination.", "Login Error", 0);
break;
}
}
BOOL CALLBACK MenuProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
switch(Message)
{
case WM_INITDIALOG:
break;
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_BTN_CONNECT:
{
/*char IP[15] = {0};
client->Connect(IP, 2500, 0, 0, 0);
if(!client->IsConnected())
;*/
break;
}
case IDC_BTN_QUIT:
PostQuitMessage(0);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_CLOSE:
PostQuitMessage(0);
break;
default:
return FALSE;
}
return TRUE;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
MSG messages;
WPARAM wParam;
InitCommonControls();
DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_MM), hWnd, MenuProc);
return messages.wParam;
}
|