12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace SuperWebSocket
- {
-
-
-
- public class JsonWebSocketSession : JsonWebSocketSession<JsonWebSocketSession>
- {
- }
-
-
-
-
- public class JsonWebSocketSession<TWebSocketSession> : WebSocketSession<TWebSocketSession>
- where TWebSocketSession : JsonWebSocketSession<TWebSocketSession>, 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));
- }
-
-
-
-
-
- public void SendJsonMessage(string name, object content)
- {
- this.Send(GetJsonMessage(name, content));
- }
- }
- }
|