void _listen_OnMsgReceived(string uid, SocketRequestMessage info) { foreach (string msg in info.Messages) { InsertText(txtMSGList, uid + ":" + msg); if (info.MessageType != SocketMessageInfoType.NONE) { SocketBaseRequest _request = SerializeHelper.JsonDeserialize <SocketBaseRequest>(msg); if (_request.ControlName == "Product" && _request.ControlFunc == "FindAll") { List <Product> _list = new List <Product>(); _list.Add(new Product() { Id = 1, Name = "a", RecommendedRetailPrice = 15, SellingPrice = 20 }); _list.Add(new Product() { Id = 2, Name = "b", RecommendedRetailPrice = 10, SellingPrice = 15 }); //DataTable _table = DBControl.DBControl.FindAll(); //foreach (DataRow row in _table.Rows) // _list.Add(new Product() { Id = (int)row[0], Name = row[1].ToString(), RecommendedRetailPrice = (decimal)row[2], SellingPrice = (decimal)row[3] }); SocketBaseResponse <Product> _response = new SocketBaseResponse <Product>() { Success = true, Message = "Successfull", Context = _list }; _listen.SendMessageAsync(uid, SerializeHelper.JsonSerializer(_response), false, info.MessageType); } } } }
void _client_OnMsgReceived(SocketRequestMessage info) { foreach (string msg in info.Messages) { InsertText(txtMSGList, msg); } }
public void Send <T>(SocketRequestMessage <T> message) { if (socket.getStatus() == USocket.STATUS_CONNECTED) { Frame f = socketProtocol.EncodeMessage(message); socket.Send(f); } }
public MessageSendCallBack SendRequest(SocketRequestMessage request) { this.requestMessage = Unpooled.Buffer(MessageSendSettings.Size); var callBack = new MessageSendCallBack(request); this.callBackActions.TryAdd(request.MessageId, callBack); this.requestMessage.WriteBytes(this.serializer.Serialize(request)); this.channelContext.WriteAndFlushAsync(this.requestMessage); return(callBack); }
public MessageSendCallBack(SocketRequestMessage request) { this.request = request; }