jQuery Messaging Events

In order to send and receive events you will have to use the standard jQuery Trigger and On methods from the client (not the game). You send a message by triggering the CKjsMessageSend event with your message as the parameter. This will trigger the C2 Condition Message Received and possibly Command Received (Depends on the command parameter). You will need to register for the CKjsMessageReceive event in order to get messages sent by the game using the Send Message Action.

CKjsMessageSend

This is the event you will trigger from the client in order to send a message to the game. Here is an example of sending the command "MyCommand":

$(document).trigger('CKjsMessageSend','MyCommand');

This will trigger the Message Received condition and if you've setup a Command Received condition for "MyCommand" it will trigger it too.

 

CKjsMessageReceive

In order to receive messages in the client sent from the game with the Send Message Action, you will need to register for this event. Here is a simple example that just outputs the message to the console:

$(document).on('CKjsMessageReceive',function(e,m){console.log(m);});

Last edited Jan 20, 2015 at 5:27 PM by theChrisKent, version 3