예제 #1
0
        bool ToClient(int clientSocketId, Message message, TimeSpan?requestConfirmTimeout)
        {
            SocketMessageServer server = _server;

            if (server == null)
            {
                return(false);
            }

            ServerAccessControl accessControl = AccessControl;

            if (accessControl != null)
            {
                if (accessControl.IsAllowed(ObtainClientAccessControl(clientSocketId)) == false)
                {
#if Matrix_Diagnostics
                    InstanceMonitor.OperationWarning("Message [" + message.ToString() + "] was not sent to client [" + clientSocketId + "] due to access control.");
#endif
                    return(false);
                }
            }

            message.MessageId = PendingMessageId;
            return(server.SendAsync(clientSocketId, message, requestConfirmTimeout));
        }
예제 #2
0
        void ApplicationLifetimeHelper_ApplicationClosingEvent()
        {
            SocketMessageServer server = _server;

            if (server != null)
            {
                server.SendAsync(new StateUpdateMessage()
                {
                    MessageId       = PendingMessageId,
                    State           = StateUpdateMessage.StateEnum.Shutdown,
                    RequestResponse = false
                }, null);

                // Allow a little time for the status update message(s) to travel.
                Thread.Sleep(150);
            }
        }