Пример #1
0
        private void WsSourceOnMessageEvent(WsMessageType msgType, string message)
        {
            switch (msgType)
            {
            case WsMessageType.Opened:
                OnConnectEvent();
                StartPingAliveLogic();
                StartPortfolioRequester();
                break;

            case WsMessageType.Closed:
                OnDisconnectEvent();
                break;

            case WsMessageType.StringData:
                _queueMessagesReceivedFromExchange.Enqueue(message);
                break;

            case WsMessageType.Error:
                SendLogMessage(message, LogMessageType.Error);
                break;

            default:
                throw new NotSupportedException(message);
            }
        }
Пример #2
0
        private void WsSourceOnMessageEvent(WsMessageType msgType, string data)
        {
            switch (msgType)
            {
            case WsMessageType.Opened:
                OnConnectEvent();
                GetSecuritiesInfo();
                StartOrderSender();
                StartPortfolioRequester();
                break;

            case WsMessageType.Closed:
                OnDisconnectEvent();
                break;

            case WsMessageType.StringData:
                _queueMessagesReceivedFromExchange.Enqueue(data);
                break;

            case WsMessageType.Error:
                SendLogMessage(data, LogMessageType.Error);
                break;

            default:
                throw new NotSupportedException(data);
            }
        }
Пример #3
0
        private void WsSourceOnMessageEvent(WsMessageType message_type, string message)
        {
            switch (message_type)
            {
            case WsMessageType.Opened:
                SendLoginMessage();
                OnConnectEvent();
                StartPortfolioRequester();
                break;

            case WsMessageType.Closed:
                OnDisconnectEvent();
                break;

            case WsMessageType.StringData:
                queue_messages_received_from_fxchange.Enqueue(message);
                break;

            case WsMessageType.Error:
                SendLogMessage(message, LogMessageType.Error);
                break;

            default:
                throw new NotSupportedException(message);
            }
        }
Пример #4
0
        public void SendMessage <T>(WsMessageType type, T obj)
        {
            var wsMessage = new WsMessage();

            wsMessage.Type    = type;
            wsMessage.From    = "Server";
            wsMessage.Message = JsonConvert.SerializeObject(obj);
            var send = JsonConvert.SerializeObject(wsMessage);

            Server.MulticastText(send);
        }
Пример #5
0
        private void WsSourceOnByteDataEvent(WsMessageType msgType, byte[] data)
        {
            switch (msgType)
            {
            case WsMessageType.ByteData:
                string message = GZipDecompresser.Decompress(data);
                _queueMessagesReceivedFromExchange.Enqueue(message);
                break;

            default:
                throw new NotSupportedException(data.ToString());
            }
        }
Пример #6
0
        /// <summary>
        /// Implements the IWsServiceEndpoint.ProcessRequest method.
        /// Gets a service operation based on the action property sent in the soap header and calls
        /// invoke on the service method.
        /// </summary>
        /// <param name="header">A WsWsaHeader containing the header proerties of a request.</param>
        /// <param name="envelope">A WsXmlDocument containing the entire envelope of the message in a node tree.</param>
        /// <returns>A byte array containing a soap response to the request.</returns>
        private byte[] ProcessRequest(WsWsaHeader header, XmlReader reader)
        {
            String action = header.Action;

            // Display the action name.
            System.Ext.Console.Write("Action: " + action);

            // Look for a valid service Action
            WsServiceOperation operation = m_serviceOperations[action];
            if (operation != null)
            {
                m_messageType = WsMessageType.Soap;
                System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(operation.MethodName);
                if (methodInfo == null)
                {
                    System.Ext.Console.Write("");
                    System.Ext.Console.Write("Operation method for action " + header.Action + " was not found");
                    System.Ext.Console.Write("");
                    throw new WsFaultException(header, WsFaultType.WsaDestinationUnreachable);
                }

                return (byte[])methodInfo.Invoke(this, new object[] { header, reader });
            }

            // Else look for event subscription Action
            if (action.IndexOf(WsWellKnownUri.WseNamespaceUri) == 0)
            {
                action = action.Substring(47/*WsWellKnownUri.WseNamespaceUri.Length + 1*/);
                switch (action)
                {
                    case "Subscribe":
                        return Subscribe(header, reader);
                    case "Unsubscribe":
                        return Unsubscribe(header, reader);
                    case "GetStatus":
                        return GetStatus(header, reader);
                    case "Renew":
                        return Renew(header, reader);
                }
            }

            // If a valid Action is not found, fault
            throw new WsFaultException(header, WsFaultType.WsaDestinationUnreachable, "To: " + header.To + " Action: " + action);
        }
Пример #7
0
        // Implements the IWsServiceEndpoint.ProcessRequest method.
        // Gets a service callback method based on the action property sent in a soap header and calls
        // invoke on the callback method.
        private byte[] ProcessRequest(WsWsaHeader header, XmlReader reader)
        {
            WsServiceOperation callback;

            // Look for a client event sink callback action
            if ((callback = m_eventCallbacks[header.Action]) != null)
            {
                m_messageType = WsMessageType.Soap;
                System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(callback.MethodName);
                if (methodInfo == null)
                {
                    System.Ext.Console.Write("");
                    System.Ext.Console.Write("Client event callback method for action " + header.Action + " was not found");
                    System.Ext.Console.Write("");
                }

                return((byte[])methodInfo.Invoke(this, new object[] { header, reader }));
            }

            // If a valid Action is not found, fault
            throw new WsFaultException(header, WsFaultType.WsaDestinationUnreachable, "To: " + header.To + " Action: " + header.Action);
        }
Пример #8
0
        private void MarketDataSourceOnMessageEvent(WsMessageType msgType, byte[] data)
        {
            switch (msgType)
            {
            case WsMessageType.Opened:
                break;

            case WsMessageType.Closed:
                OnDisconnectEvent();
                break;

            case WsMessageType.ByteData:
                string message = GZipDecompresser.Decompress(data);
                _queueMarketDataReceivedFromExchange.Enqueue(message);
                break;

            case WsMessageType.Error:
                break;

            default:
                throw new NotSupportedException("");
            }
        }
Пример #9
0
        // Implements the IWsServiceEndpoint.ProcessRequest method.
        // Gets a service callback method based on the action property sent in a soap header and calls
        // invoke on the callback method.
        private byte[] ProcessRequest(WsWsaHeader header, XmlReader reader)
        {
            WsServiceOperation callback;

            // Look for a client event sink callback action
            if ((callback = m_eventCallbacks[header.Action]) != null)
            {
                m_messageType = WsMessageType.Soap;
                System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(callback.MethodName);
                if (methodInfo == null)
                {
                    System.Ext.Console.Write("");
                    System.Ext.Console.Write("Client event callback method for action " + header.Action + " was not found");
                    System.Ext.Console.Write("");
                }

                return (byte[])methodInfo.Invoke(this, new object[] { header, reader });
            }

            // If a valid Action is not found, fault
            throw new WsFaultException(header, WsFaultType.WsaDestinationUnreachable, "To: " + header.To + " Action: " + header.Action);
        }
Пример #10
0
 private static string EncdoeMessage(string even, WsMessageType type, string data)
 {
     return($"{MESSAGE_PREFIX}{even}{MESSAGE_SEPARATOR}{type}{MESSAGE_SEPARATOR}{data}");
 }