public override void AddEvent()
 {
     base.AddEvent();
     NetMsgHandler.AddListener(NetMessageConst.StatusEvent, StatusEvent);
     NetMsgHandler.AddListener(NetMessageConst.UpdateAllDeviceInfo, UpdateAllDeviceInfo);
     GetToggleListReq();
     GetDevicesListReq();
 }
Example #2
0
 void UpdateMsg()
 {
     if (_webData.MsgQueue.Count > 0)
     {
         string   info = _webData.MsgQueue.Dequeue();
         JSONNode json = JSON.Parse(info);
         NetMsgHandler.SendMsg(json["Type"].ToString().Trim('"'), json["Data"].ToString());
     }
 }
Example #3
0
 public void Unload()
 {
     downSprites.Clear();
     if (_webData.WebSocket != null)
     {
         _webData.WebSocket.Close();
     }
     NetMsgHandler.ClearAllListeners();
     Util.LogWarning("~NetworkManager was destroy");
 }
 public void RemoveServiceListener(int stype, NetMsgHandler handler)
 {
     if (dic.ContainsKey(stype))
     {
         dic[stype] -= handler;
         if (dic[stype] == null)
         {
             dic.Remove(stype);
         }
     }
 }
 public void AddServiceListener(int stype, NetMsgHandler handler)
 {
     if (dic.ContainsKey(stype))
     {
         dic[stype] += handler;
     }
     else
     {
         dic.Add(stype, handler);
     }
 }
Example #6
0
 void GetDevicesListResp(string msg)
 {
     Debug.Log(msg);
     devicesDG.Destroy();
     devicesData         = JSON.Parse(msg);
     devicesDG.MaxLength = devicesData.Count;
     ItemRender[] dgirs = devicesDG.getItemRenders();
     for (int i = 0; i < dgirs.Length; i++)
     {
         dgirs[i].AddItemSetDataFunc((int index) =>
         {
             SetToggleItemDate(dgirs[i].gameObj, devicesData[index]);
         });
         int idx = dgirs[i].m_renderData;
         SetToggleItemDate(dgirs[i].gameObj, devicesData[idx]);
     }
     NetMsgHandler.SendMsg(NetMessageConst.UpdateAllDeviceInfo, devicesData.Count.ToString());
 }
 public void RegisterMsgHandler(EMsgCS type, NetMsgHandler handler)
 {
     _netProxyRoom.RegisterMsgHandler((byte)type, handler);
 }
 public void RegisterMsgHandler(EMsgCL type, NetMsgHandler handler)
 {
     _netProxyLobby.RegisterMsgHandler((byte)type, handler);
 }
Example #9
0
    public void Add(int protocolId, System.Action <int> action)
    {
        NetMsgHandler handler = new NetMsgHandler(action);

        handlers.Add(protocolId, handler);
    }
Example #10
0
    public void Add <T>(int protocolId, System.Action <int, T> action) where T : IMessage, new()
    {
        NetMsgHandler <T> handler = new NetMsgHandler <T>(action);

        handlers.Add(protocolId, handler);
    }
Example #11
0
 public void RegisterMsgHandler(int msgType, NetMsgHandler handler)
 {
     _allMsgDealFuncs[msgType] = handler;
 }
Example #12
0
 public static Exception ServerClosedTCPStream()
 {
     NetMsgHandler.SendMsg(NetMessageConst.SocketServerClosed, string.Empty);
     return(new Exception("TCP Stream closed unexpectedly by the remote server"));
 }
Example #13
0
 public override void RemoveEvent()
 {
     base.RemoveEvent();
     NetMsgHandler.RemoveListener(NetMessageConst.SameCamera, UpdateCameraRotation);
 }
 public override void RemoveEvent()
 {
     base.RemoveEvent();
     NetMsgHandler.RemoveListener(NetMessageConst.StatusEvent, StatusEvent);
     NetMsgHandler.RemoveListener(NetMessageConst.UpdateAllDeviceInfo, UpdateAllDeviceInfo);
 }