示例#1
0
        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
        }
示例#2
0
        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
            });
        }
示例#3
0
        void OnOpen(IWebSocketConnection aContext)
        {
            Log.Info("OnOpen(" + aContext.ConnectionInfo.ClientIpAddress + ")");

            var user = new User
            {
                Connection = aContext,
                LastSearch = Guid.Empty
            };

            _users.Add(user);
        }