void Unicast(User aUser, Response aResponse) { string message = JsonConvert.SerializeObject(aResponse, JsonSerializerSettings); #if !UNSAFE try { #endif aUser.Connection.Send(message); Log.Info("Unicast(" + aUser.Connection.ConnectionInfo.ClientIpAddress + ", " + message + ")"); #if !UNSAFE } catch (Exception ex) { Log.Fatal("Unicast(" + aUser.Connection.ConnectionInfo.ClientIpAddress + ", " + message + ")", ex); } #endif }
void UnicastBlock(User aUser, string aType, IEnumerable<AObject> aObjects) { Unicast(aUser, new Response { Type = Response.Types.BlockStart, Data = aType }); foreach (AObject aObject in aObjects) { Unicast(aUser, new Response { Type = Response.Types.ObjectAdded, Data = aObject }); } Unicast(aUser, new Response { Type = Response.Types.BlockStop, Data = aType }); }
void OnOpen(IWebSocketConnection aContext) { Log.Info("OnOpen(" + aContext.ConnectionInfo.ClientIpAddress + ")"); var user = new User { Connection = aContext, LastSearch = Guid.Empty }; _users.Add(user); }