public void ConnectionExtablished(SocketIOEvent ev)
        {
            Debug.Log("first scene");
            ChangeGameState(authState);
            Dictionary <string, string> data = new Dictionary <string, string>();

            data["PLAYER_ID"]   = PlayerPrefs.GetInt("PLAYER_ID", 0).ToString();
            data["PLAYER_NAME"] = PlayerPrefs.GetString("PLAYER_NAME", "SETHUNATH").ToString();
            Debug.Log("sending authrequest");
            connectionController.Emit("USER_AUTH_REQUEST", new JSONObject(data));
        }
示例#2
0
    void Awake()
    {
        ws = GameObject.FindGameObjectWithTag("ServerController").
             GetComponent <ConnectionController> ();

        ws.OnConnect((sender, e) => {
            Debug.Log("Connected at server");
            ws.Emit("login", nickname);
            loginPanel.SetActive(false);
            chatPanel.SetActive(true);
        });

        ws.On("message", (data) => {
            ChatMessage chatMessage = JsonConvert.DeserializeObject <ChatMessage> (data);

            Vector3 framePos = new Vector3(content.position.x,
                                           content.position.y,
                                           content.position.z);

            GameObject goFrame = Instantiate(messageFrame,
                                             framePos,
                                             Quaternion.identity)
                                 as GameObject;

            goFrame.transform.SetParent(content);

            MessageFrame mf      = goFrame.GetComponent <MessageFrame> ();
            mf.nameFrame.text    = chatMessage.name;
            mf.messageFrame.text = chatMessage.message;

            messageField.text = "";
        });
    }
示例#3
0
 public void SendButton()
 {
     Debug.Log("Enviar mensagem: " + messageField.text);
     if (!String.IsNullOrEmpty(messageField.text) &&
         !String.IsNullOrWhiteSpace(messageField.text))
     {
         ws.Emit("message", messageField.text);
     }
 }