public bool Receive(string command, object response, long resTime) { if (command.Equals("9201")) { NPCloudReceiveParameter <string> npcloudReceiveParameter = response as NPCloudReceiveParameter <string>; NpMessageParameter obj = new NpMessageParameter(npcloudReceiveParameter.option.roomId, (int)npcloudReceiveParameter.sender, npcloudReceiveParameter.body, NpUtil.MsTimestampToDateTime(npcloudReceiveParameter.resTime)); this.mMessage(obj); return(true); } if (command.Equals("9202")) { NPCloudReceiveParameter <List <RoomMsgLog> > npcloudReceiveParameter2 = response as NPCloudReceiveParameter <List <RoomMsgLog> >; List <NpRoomMsgLog> list = new List <NpRoomMsgLog>(); foreach (RoomMsgLog roomMsgLog in npcloudReceiveParameter2.body) { DateTime sendtime = NpUtil.MsTimestampToDateTime(roomMsgLog.createdat); if (!string.IsNullOrEmpty(roomMsgLog.userid) || !string.IsNullOrEmpty(roomMsgLog.sendedmsg)) { NpRoomMsgLog item = new NpRoomMsgLog(roomMsgLog.userid, sendtime, roomMsgLog.sendedmsg); list.Add(item); } } this.mRoomMsgLog(list); return(true); } return(false); }
public void Update() { byte[] array = null; while (this.SocketInstance != null) { NPCloudReceiveParameter <NPCloudReceiveHashParaemter> requestParameter = this.SocketInstance.GetRequestParameter <NPCloudReceiveParameter <NPCloudReceiveHashParaemter> >(out array); if (requestParameter == null || array == null) { break; } string[] array2 = requestParameter.command.Split(new char[] { ':' }); NPCloudReceiveParameter <NpCloudVenusErrorParameter> npcloudReceiveParameter = NpMessagePack.Unpack <NPCloudReceiveParameter <NpCloudVenusErrorParameter> >(array); NpCloudErrorData npCloudErrorData = new NpCloudErrorData(); npCloudErrorData.command = array2[1]; npCloudErrorData.resultCode = requestParameter.resultCode; npCloudErrorData.resultMsg = requestParameter.resultMsg; npCloudErrorData.venus = npcloudReceiveParameter.body; if (requestParameter.resultCode == null || !requestParameter.resultCode.Equals("0")) { if (requestParameter.resultCode == "406") { throw new NpCloudException(712, requestParameter.body.shardingServ); } for (int i = 0; i < this.mListenerlist.Count; i++) { if (this.mListenerlist[i].ReceiveException(npCloudErrorData)) { } } this.mListener.OnRequestException(npCloudErrorData); } object receiveData = null; string text = array2[1]; if (text == null) { goto IL_2EA; } if (NpCloudManager.< > f__switch$map0 == null) { NpCloudManager.< > f__switch$map0 = new Dictionary <string, int>(8) { { string.Empty, 0 }, { "9100", 1 }, { "9101", 1 }, { "9102", 1 }, { "9105", 1 }, { "9106", 1 }, { "9201", 2 }, { "9202", 3 } }; } int num; if (!NpCloudManager.< > f__switch$map0.TryGetValue(text, out num)) { goto IL_2EA; } switch (num) { case 0: if (array2[0].Equals(NpCloudValueType.send.ToString())) { NPCloudReceiveParameter <Dictionary <string, object> > npcloudReceiveParameter2 = NpMessagePack.Unpack <NPCloudReceiveParameter <Dictionary <string, object> > >(array); this.mListener.OnResponse((int)npcloudReceiveParameter2.sender, npcloudReceiveParameter2.body); } else if (array2[0].Equals(NpCloudValueType.finduser.ToString())) { NPCloudReceiveParameter <NpCloudReceiveFindUserParameter> npcloudReceiveParameter3 = NpMessagePack.Unpack <NPCloudReceiveParameter <NpCloudReceiveFindUserParameter> >(array); List <string> on = npcloudReceiveParameter3.body.on; if (NpCloudManager.< > f__mg$cache0 == null) { NpCloudManager.< > f__mg$cache0 = new Converter <string, int>(int.Parse); } List <int> on2 = on.ConvertAll <int>(NpCloudManager.< > f__mg$cache0); List <string> off = npcloudReceiveParameter3.body.off; if (NpCloudManager.< > f__mg$cache1 == null) { NpCloudManager.< > f__mg$cache1 = new Converter <string, int>(int.Parse); } List <int> off2 = off.ConvertAll <int>(NpCloudManager.< > f__mg$cache1); this.mListener.OnFindUser(on2, off2); } continue; case 1: receiveData = this.SocketInstance.Deserialize <NpCloudReceiveRoomParameter>(requestParameter.body.data); break; case 2: receiveData = NpMessagePack.Unpack <NPCloudReceiveParameter <string> >(array); break; case 3: receiveData = NpMessagePack.Unpack <NPCloudReceiveParameter <List <RoomMsgLog> > >(array); break; case 4: goto IL_2EA; default: goto IL_2EA; } IL_30C: for (int j = 0; j < this.mListenerlist.Count; j++) { if (this.mListenerlist[j].Receive(array2[1], receiveData, requestParameter.resTime)) { } } continue; IL_2EA: NPCloudReceiveParameter <Dictionary <string, object> > npcloudReceiveParameter4 = NpMessagePack.Unpack <NPCloudReceiveParameter <Dictionary <string, object> > >(array); this.mListener.OnCtrlResponse(array2[1], npcloudReceiveParameter4.body); goto IL_30C; } }