/// <summary>
 /// Called when the web socket closed
 /// </summary>
 void OnClosed(WebSocket ws, UInt16 code, string message)
 {
     Debug.Log("Unity:" + string.Format("-WebSocket closed! Code: {0} Message: {1}\n", code, message));
     _webSocket = null;
     if (m_WebSocketSimpet != null && Application.isPlaying)
     {
         Debug.Log("Unity:" + "OnClosed::Restart Web Socket -> url == " + Address);
         m_WebSocketSimpet.OpenWebSocket(Address);
     }
 }
Exemple #2
0
    /// <summary>
    /// 链接游戏服务器.
    /// </summary>
    void ConnectWebSocketServer()
    {
        if (m_BoxLoginRt != BoxLoginRt.Success)
        {
            Debug.Log("Unity:" + "ConnectWebSocket -> m_BoxLoginRt == " + m_BoxLoginRt);
            return;
        }

        string url = "ws://" + m_BoxLoginDt.serverIp + "/websocket.do?token=" + m_BoxLoginDt.token;

        Debug.Log("Unity:" + "ConnectWebSocket -> url " + url);
        if (m_WebSocketSimpet != null)
        {
            m_WebSocketSimpet.OpenWebSocket(url);
        }
    }