public override void ExecuteCommand(TWebSocketSession session, SubRequestInfo requestInfo) { if (string.IsNullOrEmpty(requestInfo.Data)) { ExecuteJsonCommand(session, default(TJsonCommandInfo)); return; } TJsonCommandInfo jsonCommandInfo; if (!string.IsNullOrEmpty(requestInfo.Token)) { session.CurrentToken = requestInfo.Token; } if (!m_IsPrimitiveType) { ///??????????????????????????????????????????? //jsonCommandInfo = JsonConvert.DeserializeObject<TJsonCommandInfo>(requestInfo.Data); jsonCommandInfo = System.Json.Converter.Deserialize <TJsonCommandInfo>(requestInfo.Data); } else { jsonCommandInfo = (TJsonCommandInfo)Convert.ChangeType(requestInfo.Data, m_CommandInfoType); } ExecuteJsonCommand(session, jsonCommandInfo); }
/// <summary> /// Executes the command. /// </summary> /// <param name="session">The session.</param> /// <param name="requestInfo">The request info.</param> public override void ExecuteCommand(TWebSocketSession session, SubRequestInfo requestInfo) { if (string.IsNullOrEmpty(requestInfo.Body)) { ExecuteJsonCommand(session, default(TJsonCommandInfo)); return; } TJsonCommandInfo jsonCommandInfo; if (!string.IsNullOrEmpty(requestInfo.Token)) { session.CurrentToken = requestInfo.Token; } if (!m_IsSimpleType) { jsonCommandInfo = (TJsonCommandInfo)session.AppServer.JsonDeserialize(requestInfo.Body, m_CommandInfoType); } else { jsonCommandInfo = (TJsonCommandInfo)Convert.ChangeType(requestInfo.Body, m_CommandInfoType); } ExecuteJsonCommand(session, jsonCommandInfo); }
public override void ExecuteCommand(MessageSocketSession session, SuperWebSocket.SubProtocol.SubRequestInfo requestInfo) { session.Cookies["ConnectTime"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); string body = Careysoft.Basic.Public.DES.Decrypt(requestInfo.Body, session.Cookies["PrivateKey"]); session.EventMessageServerSessionExcute(new Model.EventMessageServerModel(EnumMessageInfo.Log, "MessagePoint", session.SessionID + " " + body)); Sender.Sender.SendMessageToGroup(session.AppServer as MessageSocketServer, body); }
public override void ExecuteCommand(MessageSocketSession session, SuperWebSocket.SubProtocol.SubRequestInfo requestInfo) { Model.ClientModel clientModel = Access.Auth.AuthClientType(requestInfo.Body); if (clientModel == null) { //Console.WriteLine(String.Format("{0} code error, refuse", session.SessionID)); session.Close(); } else { string privatekey = Careysoft.Basic.Public.FString.GetRandomString(8); session.Cookies.Add("ClientCode", clientModel.ClientCode); session.Cookies.Add("ClientType", clientModel.ClientType.ToString()); session.Cookies.Add("GroupCode", clientModel.GroupCode); session.Cookies.Add("PrivateKey", privatekey); session.Cookies.Add("ConnectTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); session.Send(String.Format("{0} {1}", Model.EnumCommand.AuthAccept, Careysoft.Basic.Public.DES.Encrypt(privatekey, DateTime.Now.AddDays(-1).ToString("yyyyMMdd")))); } }
/// <summary> /// Executes the command. /// </summary> /// <param name="session">The session.</param> /// <param name="requestInfo">The request info.</param> public override void ExecuteCommand(TWebSocketSession session, SubRequestInfo requestInfo) { if (string.IsNullOrEmpty(requestInfo.Body)) { ExecuteJsonCommand(session, default(TJsonCommandInfo)); return; } TJsonCommandInfo jsonCommandInfo; LocalDataStoreSlot tokenSlot = null; if (!string.IsNullOrEmpty(requestInfo.Token)) { tokenSlot = session.SetCurrentToken(requestInfo.Token); } try { if (!m_IsSimpleType) { jsonCommandInfo = (TJsonCommandInfo)session.AppServer.JsonDeserialize(requestInfo.Body, m_CommandInfoType); } else { jsonCommandInfo = (TJsonCommandInfo)Convert.ChangeType(requestInfo.Body, m_CommandInfoType); } ExecuteJsonCommand(session, jsonCommandInfo); } finally { if (tokenSlot != null) { Thread.SetData(tokenSlot, null); } } }