public IWebScoketHandler webSocketNewConnectionHandler(WebSocketContext context, uint id) { bool isSecureConnection = context.IsSecureConnection; UserConnectionInfo userConnection; oldConnections.TryRemove(id, out userConnection); //try to get old connection if (userConnection == null) // if no old connection found create new object { userConnection = new UserConnectionInfo(isSecureConnection, id, this); } else { userConnection.resubscribeObserver(); } bool addAns = activeConnections.TryAdd(id, userConnection); if (!addAns) { //Console.WriteLine("error in adding to dictionary in Communication manager"); Logger.Log("error", logLevel.ERROR, "error in adding new connection to dictionary in Communication manager"); return(null); } return(this); }
private string handlePostRequest(HttpListenerRequest request) { using (var reader = new System.IO.StreamReader(request.InputStream)) { string content = reader.ReadToEnd(); UserConnectionInfo curr = new UserConnectionInfo(false, 0, null); return(curr.stresshelp(content, request.RawUrl)); } }
public void onMessage(List <byte[]> bufferCollector, WebSocketReceiveResult receiveResult, uint myId) { UserConnectionInfo userConnection = activeConnections[myId]; userConnection.onMessage(bufferCollector, receiveResult); }