Hi,
I have done an application in combination with RakNet.Well,the registration which is done with password sending,is going OK and the two sides can communicate.But,when I press the 'N' button,the engine is supposed to send a message to the client to tell him to load some staff.
I think the problem is that the press button event is not accepted in other pc's except mine.So the packet is not sent to the clients.
Can you tell me what might be wrong?
Thanks...
In other Pc's the Press_button Event does not work!!!
Well,when the client press the 'N' button, it's supposed to send a message to the server,but the message is not sent.The fact is that all the other messages(like the string password for the authorization) are sent normally.I think the problem is from the Irrlicht engine which cannot take the press button events in other machines.The strange is that in my machine,when running the .exe's files,everything work perfectly.
okay this is a bit confusing. You have two machine right, one is running some server code and one is running client code. When you press the 'N' button on the client you want to send a message to the server. I understand all that, what i don't understand is why you would be recieving the button press event in the server.
I would suggest detecting the button press on the client, the clients event handler should then send a message to the server. The server should detect this message using you network code and then do its own processing.
I really don't understand why you think this is a problem with irrlicht, communication between the two machines should be handled completly through your network code, events on both machine should be abstracted through this. The server should not detect that the N button was pressed on a client, it should just respond to any message sent by the client.
I would suggest detecting the button press on the client, the clients event handler should then send a message to the server. The server should detect this message using you network code and then do its own processing.
I really don't understand why you think this is a problem with irrlicht, communication between the two machines should be handled completly through your network code, events on both machine should be abstracted through this. The server should not detect that the N button was pressed on a client, it should just respond to any message sent by the client.
Well,I do not want to receive the button press event to the server,but I want my client application to be able to take from the user the press of the button from the keyboard.In my machine(on my home) everything go OK,but in other machines(in work)the press button event does not correspond.
Since the Irrlicht engine has the ability to detect events from keyboard,I would like to use it,so when the user in client end press the 'N' key,I added RakNet code to send a distinct message.But the key is not "pressed".I think I am clear now.
BTW:Any other messages(like password input in dos mode) are OK.
Since the Irrlicht engine has the ability to detect events from keyboard,I would like to use it,so when the user in client end press the 'N' key,I added RakNet code to send a distinct message.But the key is not "pressed".I think I am clear now.
BTW:Any other messages(like password input in dos mode) are OK.
My O/S is XP Pro both in work and at home.
My code is the following:
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (event.EventType == irr::EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown)
switch(event.KeyInput.Key)
{
case KEY_KEY_N:
{
BitStream bitstream;
bitstream.Write((unsigned char)ID_NEXT_MOVE);
CLIENT->Send(&bitstream,HIGH_PRIORITY, RELIABLE_ORDERED, 0);
return true;
}
/* case KEY_KEY_C:
{
camera->setPosition(core::vector3df(5850*2,2500*2,13800*2));
camera->setTarget(core::vector3df(8500*2,343*2,-19000*2));
return true;
}*/
case KEY_KEY_S:
{
BitStream bitstream;
bitstream.Write((unsigned char)ID_CHANGE_STORY);
CLIENT->Send(&bitstream,HIGH_PRIORITY, RELIABLE_ORDERED, 0);
return true;
}
}
return false;
}
};
My code is the following:
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (event.EventType == irr::EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown)
switch(event.KeyInput.Key)
{
case KEY_KEY_N:
{
BitStream bitstream;
bitstream.Write((unsigned char)ID_NEXT_MOVE);
CLIENT->Send(&bitstream,HIGH_PRIORITY, RELIABLE_ORDERED, 0);
return true;
}
/* case KEY_KEY_C:
{
camera->setPosition(core::vector3df(5850*2,2500*2,13800*2));
camera->setTarget(core::vector3df(8500*2,343*2,-19000*2));
return true;
}*/
case KEY_KEY_S:
{
BitStream bitstream;
bitstream.Write((unsigned char)ID_CHANGE_STORY);
CLIENT->Send(&bitstream,HIGH_PRIORITY, RELIABLE_ORDERED, 0);
return true;
}
}
return false;
}
};