using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SuperWebSocket { /// /// Json websocket session /// public class JsonWebSocketSession : JsonWebSocketSession { } /// /// Json websocket session /// /// The type of the web socket session. public class JsonWebSocketSession : WebSocketSession where TWebSocketSession : JsonWebSocketSession, new() { private const string m_QueryTemplate = "{0} {1}"; private string GetJsonMessage(string name, object content) { if(content.GetType().IsSimpleType()) return string.Format(m_QueryTemplate, name, content); else return string.Format(m_QueryTemplate, name, AppServer.JsonSerialize(content)); } /// /// Sends the json message. /// /// The name. /// The content. public void SendJsonMessage(string name, object content) { this.Send(GetJsonMessage(name, content)); } } }