当前位置: 首页>>代码示例>>C#>>正文


C# MessageTypes.ToString方法代码示例

本文整理汇总了C#中MessageTypes.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# MessageTypes.ToString方法的具体用法?C# MessageTypes.ToString怎么用?C# MessageTypes.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MessageTypes的用法示例。


在下文中一共展示了MessageTypes.ToString方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: sendmessage

        public static bool sendmessage(MessageTypes type, string msg, ref byte[] data)
        {
            try
            {
                System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
                byte[] message = encoding.GetBytes(msg);
                int size = HEADERSIZE + message.Length;
                data = new byte[size];
                byte[] sizebyte = BitConverter.GetBytes(size);
                byte[] typebyte = BitConverter.GetBytes((int)type);
                Array.Copy(sizebyte, 0, data, LENGTHOFFSET, sizebyte.Length);
                Array.Copy(typebyte, 0, data, TYPEOFFSET, typebyte.Length);
                Array.Copy(message, 0, data, HEADERSIZE, message.Length);
            }
#if DEBUG
            catch (Exception ex)
            {
                Console.WriteLine("error processing: " + type.ToString() + " msg: " + msg + " err: " + ex.Message + ex.StackTrace);
                return false;
            }
#else
            catch (Exception)
            {
            }
#endif

            return true;

            
        }
开发者ID:bluejack2000,项目名称:core,代码行数:30,代码来源:Message.cs

示例2: tl_newUnknownRequest

 long tl_newUnknownRequest(MessageTypes t, string msg)
 {
     v("message: " + t.ToString() + " data: " + msg);
     switch (t)
     {
         case MessageTypes.DOMREQUEST:
             {
                 string client = string.Empty;
                 int depth = 0;
                 if (Book.ParseDOMRequest(msg, ref depth, ref client))
                 {
                     debug("depth set to: " + depth + " by client: " + client);
                     tickdepth = depth;
                 }
                 break;
             }
         case MessageTypes.DAYHIGH:
             {
                 decimal price = 0;
                 highs.TryGetValue(msg, out price);
                 return WMUtil.pack(price);
             }
         case MessageTypes.DAYLOW:
             {
                 decimal price = 0;
                 lows.TryGetValue(msg, out price);
                 return WMUtil.pack(price);
             }
     }
     return (long)MessageTypes.UNKNOWN_MESSAGE;
 }
开发者ID:bluejack2000,项目名称:core,代码行数:31,代码来源:Replay.cs

示例3: TLSend

        /// <summary>
        /// send a message to providers
        /// </summary>
        /// <param name="type"></param>
        /// <param name="source"></param>
        /// <param name="dest"></param>
        /// <param name="msgid"></param>
        /// <param name="message"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public long TLSend(MessageTypes type, long source, long dest, long msgid, string message, ref string result)
        {
            v(type.ToString() + " sending to all providers: "+message);
            for (int i = 0; i < _pcon.Count; i++)
                if (_pcon[i].RequestFeatureList.Contains(type))
                {
                    bool showret = false;
                    // prepare message
                    switch (type)
                    {
                        case MessageTypes.DOMREQUEST:
                            message = message.Replace(Book.EMPTYREQUESTOR, _pcon[i].Name);
                            showret = true;
                            break;
                        case MessageTypes.BARREQUEST:
                            {
                                BarRequest br = BarImpl.ParseBarRequest(message);
                                br.Client = _pcon[i].Name;
                                message = BarImpl.BuildBarRequest(br);
                                showret = true;
                            }
                            break;
                        case MessageTypes.FEATUREREQUEST:
                            message = _pcon[i].Name;
                            showret = true;
                            break;
                    }
                    long res = _pcon[i].TLSend(type, message);
                    result = res.ToString();
                    if (gotUnknownMessage != null)
                        gotUnknownMessage(type, source, dest, msgid, message, ref result);

                    return res;
                }
                else if (VerboseDebugging)
                    v(_pcon[i].BrokerName + " " + _pcon[i].Name + " does not support feature " + type + ", dropping message.");
            return 0;
        }
开发者ID:sopnic,项目名称:larytet-master,代码行数:48,代码来源:BrokerFeed.cs

示例4: SendData

        /// <summary>
        /// Sends a line to the server.
        /// </summary>
        /// <param name="messageType">The type of the message.</param>
        /// <param name="argument">The rest of the message.</param>
        public void SendData(MessageTypes messageType, string argument = "")
        {
            TimeSpan sinceLastSend = new DateTime() - LastSend;
            if (sinceLastSend.TotalMilliseconds < Config.MessageInterval)
            {
                Thread.Sleep((int)Config.MessageInterval - (int)sinceLastSend.TotalMilliseconds);
            }

            try
            {
                if (argument == "")
                {
                    _streamWriter.WriteLine(messageType.ToString());
                    _streamWriter.Flush();
                }
                else
                {
                    _streamWriter.WriteLine(messageType.ToString() + " " + argument);
                    _streamWriter.Flush();
                }
            }
            catch (IOException)
            {
                Console.WriteLine("Lost connection to server unexpectedly. Attempting to reconnect.");
                Running = false;
                _connect();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception [" + ex.GetType() + "] " + ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
            
            Console.WriteLine(messageType.ToString() + " " + argument);
            LastSend = new DateTime();
        }
开发者ID:Banane9,项目名称:Kiwana,代码行数:41,代码来源:Kiwana.cs

示例5: sendmessage

 public virtual void sendmessage(MessageTypes type, string data) 
 {
     string msg_json = "{\"type\": \"" + type.ToString("f") + "\", \"data\": \"" + data + "\"}";
     send_event(MimeType.send_message, "message", msg_json);
     
     sendmessage(type, 0, data, string.Empty); 
 }
开发者ID:RedBanies3ofThem,项目名称:tradelink.afterlife,代码行数:7,代码来源:MessageBusableResponseTemplate.cs

示例6: GotMessage

 /// <summary>
 /// called when unknown message arrives.   
 /// </summary>
 /// <param name="type"></param>
 /// <param name="id"></param>
 /// <param name="data"></param>
 public virtual void GotMessage(MessageTypes type, long source, long dest, long msgid, string request, ref string response)
 {
     string msg_json = "{\"type\": \"" + type.ToString("f") + "\", \"source\": " + source.ToString() + ", \"dest\": " + dest.ToString() + ", \"msgid\": " + msgid.ToString() + ", \"request\": \"" + request + "\",  \"response\": \"" + response + "\"}";
     send_event(MimeType.got_message, "message", msg_json);
 }
开发者ID:RedBanies3ofThem,项目名称:tradelink.afterlife,代码行数:11,代码来源:MessageBusableResponseTemplate.cs

示例7: tl_newUnknownRequest

        long tl_newUnknownRequest(MessageTypes t, string msg)
        {
            if (VerboseDebugging)
                debug("got message: " + t.ToString() + " " + msg);
            // message will be handled on main thread for com security
            _msgq.Write(new GenericMessage(t, msg));
            // we say ok for any supported messages
            switch (t)
            {
                case MessageTypes.SENDORDERPEGMIDPOINT:
                    return (long)MessageTypes.OK;
            }

            debug("Message type " + t.ToString() + ":" + msg + " was unsupported.");
            return (long)MessageTypes.UNKNOWN_MESSAGE;
        }
开发者ID:sopnic,项目名称:larytet-master,代码行数:16,代码来源:ServerSterling.cs

示例8: Send

 /// <summary>
 /// send a message with given message type and message
 /// </summary>
 /// <param name="type">type of request</param>
 /// <param name="message">body of message about information of request</param>
 public void Send(MessageTypes type, string message)
 {
     Data data = new Data(type.ToString(), message);
     Send(data);
 }
开发者ID:saeed-kamyabi,项目名称:EsmFamil,代码行数:10,代码来源:Connection.cs

示例9: SendMessage

        public virtual bool SendMessage(MessageTypes type, long source, long dest, long msgid, string request, string response)
        {
            if (_tl == null)return false;
            if (!_tl.RequestFeatureList.Contains(type))
            {
                SendDebug(type.ToString() + " not supported by " + _tl.Name);
                return false;
            }
            try
            {
                // prepare message
                switch (type)
                {
                    case MessageTypes.DOMREQUEST:
                        request = request.Replace(Book.EMPTYREQUESTOR, _tl.Name);
                        break;
                    case MessageTypes.BARREQUEST:
                        {
                            BarRequest br = BarRequest.Deserialize(request);
                            br.Client = _tl.Name;
                            request = BarRequest.Serialize(br);
                        }
                        break;
                    case MessageTypes.FEATUREREQUEST:
                        request = _tl.Name;
                        break;

                    case MessageTypes.IMBALANCEREQUEST:
                        request = _tl.Name;
                        break;
                }
                // send it
                long result = _tl.TLSend(type, request);
                string res = result.ToString();
                // pass along result
                if ((SendMessageResponse != null) && (result != 0))
                    SendMessageResponse(type, source, dest, msgid, request, ref res);
                return true;
            }
            catch (Exception ex)
            {
                debug("Error on: "+type.ToString()+ source + dest + msgid + request + response);
                debug(ex.Message + ex.StackTrace);
            }
            return false;
        }
开发者ID:bluejack2000,项目名称:core,代码行数:46,代码来源:MessageTracker.cs

示例10: ShowMesage

 private void ShowMesage(MessageTypes messageType, string message)
 {
     const string messageBoxJsTemplate = "window.RWD.MessageBox.$MessageType$('$MessageType$', '$MessageBody$');";
     string outputMessage = WebUtility.EncodeJavaScriptString(message);
     ClientScripts.OnDocumentReady.Add2BeginOfBody(messageBoxJsTemplate.Replace("$MessageType$", messageType.ToString()).Replace("$MessageBody$", outputMessage));
 }
开发者ID:TatumAndBell,项目名称:RapidWebDev-Enterprise-CMS,代码行数:6,代码来源:DynamicPageHandler.cs

示例11: report

        void report(MessageTypes type, long id, double last)
        {
            if (SendLatency == null) return;
            SendLatency(type, id, last);
            if (_logit)
            {
                string sym = string.Empty;
                _id2sym.TryGetValue(id,out sym);
                try
                {
                    if (_log == null)
                    {
                        bool exists = System.IO.File.Exists(_logpath);
                        _log = new System.IO.StreamWriter(_logpath, true);
                        if (!exists)
                            _log.WriteLine("Symbol,Message,Id,Latency");
                        _log.AutoFlush = true;
                    }
                    _log.WriteLine(string.Format("{0},{1},{2},{3:F1}", sym, type.ToString(), id, last));
                }
                catch { }
            }

        }
开发者ID:bluejack2000,项目名称:core,代码行数:24,代码来源:LatencyTracker.cs

示例12: handle

        long handle(MessageTypes type, string msg, Socket sock)
        {
            long result = NORETURNRESULT;
            v((sock!=null  ? sock.RemoteEndPoint.ToString() : string.Empty) + " " + type.ToString() + " " + msg);
            switch (type)
            {
                case MessageTypes.ACCOUNTREQUEST:
                    if (newAcctRequest == null) break;
                    string accts = newAcctRequest();
                    TLSend(accts, MessageTypes.ACCOUNTRESPONSE, sock);
                    break;
                case MessageTypes.POSITIONREQUEST:
                    if (newPosList == null) break;
                    string[] pm = msg.Split('+');
                    if (pm.Length < 2) break;
                    string client = pm[0];
                    string acct = pm[1];
                    Position[] list = newPosList(acct);
                    foreach (Position pos in list)
                        TLSend(PositionImpl.Serialize(pos), MessageTypes.POSITIONRESPONSE, client);
                    break;
                case MessageTypes.ORDERCANCELREQUEST:
                    {
                        long id = 0;
                        if (long.TryParse(msg, out id) && (newOrderCancelRequest != null))
                            newOrderCancelRequest(id);
                    }
                    break;
                case MessageTypes.SENDORDER:
                    SrvDoExecute(msg);
                    break;
                case MessageTypes.REGISTERCLIENT:
                    SrvRegClient(msg,sock);
                    break;
                case MessageTypes.REGISTERSTOCK:
                    string[] m2 = msg.Split('+');
                    SrvRegStocks(m2[0], m2[1]);
                    break;
                case MessageTypes.CLEARCLIENT:
                    SrvClearClient(msg);
                    break;
                case MessageTypes.CLEARSTOCKS:
                    SrvClearStocks(msg);
                    break;
                case MessageTypes.HEARTBEATREQUEST:
                    SrvBeatHeart(msg);
                    break;
                case MessageTypes.BROKERNAME:
                    {
                        result = (long)newProviderName;
                        sock.Send(BitConverter.GetBytes(result));
                    }
                    break;
                case MessageTypes.IMBALANCEREQUEST:
                    if (newImbalanceRequest != null) newImbalanceRequest();
                    break;
                case MessageTypes.FEATUREREQUEST:
                    string msf = "";
                    List<MessageTypes> f = new List<MessageTypes>();
                    f.Add(MessageTypes.HEARTBEATREQUEST);
                    f.Add(MessageTypes.HEARTBEATRESPONSE);
                    f.Add(MessageTypes.CLEARCLIENT);
                    f.Add(MessageTypes.CLEARSTOCKS);
                    f.Add(MessageTypes.REGISTERCLIENT);
                    f.Add(MessageTypes.REGISTERSTOCK);
                    f.Add(MessageTypes.FEATUREREQUEST);
                    f.Add(MessageTypes.FEATURERESPONSE);
                    f.Add(MessageTypes.VERSION);
                    f.Add(MessageTypes.BROKERNAME);
                    List<string> mf = new List<string>();
                    foreach (MessageTypes t in f)
                    {
                        int ti = (int)t;
                        mf.Add(ti.ToString());
                    }
                    if (newFeatureRequest != null)
                    {
                        MessageTypes[] f2 = newFeatureRequest();
                        foreach (MessageTypes t in f2)
                        {
                            int ti = (int)t;
                            mf.Add(ti.ToString());
                        }
                    }
                    msf = string.Join(",", mf.ToArray());
                    TLSend(msf, MessageTypes.FEATURERESPONSE, msg);
                    break;
                case MessageTypes.VERSION:
                    result = (long)MinorVer;
                    break;
                case MessageTypes.DOMREQUEST:
                    string[] dom = msg.Split('+');
                    SrvDOMReq(dom[0], int.Parse(dom[1]));
                    break;
                default:
                    if (newUnknownRequestSource != null)
                        result = newUnknownRequestSource(type, msg, sock.RemoteEndPoint.ToString());
                    else if (newUnknownRequest != null)
                        result = newUnknownRequest(type, msg);
                    else
//.........这里部分代码省略.........
开发者ID:antonywu,项目名称:tradelink,代码行数:101,代码来源:TLServer_IP.cs

示例13: TLSend

        public void TLSend(string msg, MessageTypes type, Socket s)
        {
            if (s.Connected)
            {
                byte[] data = Message.sendmessage(type, msg);
#if DEBUG
                v("srv sending message type: " + type + " contents: " + msg);
                v("srv sending raw data size: " + data.Length + " data: " + HexToString(data, data.Length));
#endif

                try
                {
                    s.Send(data);
                }
                catch (Exception ex)
                {
                    debug("error sending: " + type.ToString() + " " + msg);
                    debug("exception: " + ex.Message + ex.StackTrace);
                    if (DisconnectOnError)
                    {
                        debug("disconnecting from: " + s.RemoteEndPoint.ToString());
                        s.Shutdown(SocketShutdown.Both);
                        s.Disconnect(true);
                    }
                }
            }
        }
开发者ID:antonywu,项目名称:tradelink,代码行数:27,代码来源:TLServer_IP.cs

示例14: transmitSync

 public DCPRetCodes transmitSync(CommandSet a_cmd, MessageTypes a_msgType, byte[] a_msg)
 {
     try
     {
         string str = Encoding.ASCII.GetString(a_msg, 0, a_msg.GetLength(0));
         string str2 = a_cmd.ToString() + " " + a_msgType.ToString() + " msg: " + str;
         DCP_DLL.Utils.log(this, "transmitSync ", str2);
         this.checkPortAvailability();
         this._transmitFinished = false;
         DCPTelegram telegram = new DCPTelegram {
             CmdSet = a_cmd,
             MsgType = a_msgType
         };
         telegram.Data.copy(a_msg);
         this.pushTelegram(telegram, this._txFifo, this._txFifoMutex);
         while (!this._transmitFinished)
         {
             Thread.Sleep(this._ThreadSleepTime);
         }
         return this._transmitResult;
     }
     catch (Exception exception)
     {
         DCP_DLL.Utils.log(this, "transmitSync ", exception.Message);
         return DCPRetCodes.DCP_FATAL;
     }
 }
开发者ID:x893,项目名称:WDS,代码行数:27,代码来源:DCP.cs


注:本文中的MessageTypes.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。