Exemplo n.º 1
0
    void Awake()
    {
        WebSocketConnectionController.Init(
            userId,

            // connected
            () => {
            Debug.Log("connect succeeded!");
            Application.logMessageReceived += HandleLog;
            WebSocketConnectionController.SendCommand(new Commands.SetId(userId).ToString());
        },

            // messages comes from server
            (List <string> datas) => {
            Debug.Log("datas received:" + datas.Count);
            foreach (var data in datas)
            {
                Debug.Log("data:" + data);
            }
        },

            // connect fail
            (string connectionFailReason) => {
            Debug.Log("failed to connect! by reason:" + connectionFailReason);
        },

            // error on connection
            (string connectionError) => {
            Debug.Log("failed in running! by reason:" + connectionError);
        },

            // auto reconnect
            true,
            () => {
            Debug.Log("reconnecting!");
        }
            );
    }
Exemplo n.º 2
0
 /**
  *      send log to server.
  */
 void HandleLog(string logString, string stackTrace, LogType type)
 {
     WebSocketConnectionController.SendCommand(new Commands.Log(userId, logString).ToString());
 }
Exemplo n.º 3
0
 public void OnApplicationQuit()
 {
     Debug.Log("exitting..");
     WebSocketConnectionController.CloseCurrentConnection();
 }