Ejemplo n.º 1
0
        public ISpEventMessage Response(ISpEventMessage msg)
        {
            MyMsgId   eventType = SpConverter.IntToEnum <MyMsgId>(msg.EventId);
            MyMsgType msgType   = SpConverter.IntToEnum <MyMsgType>(msg.TypeId);

            // All my messages are Simple Types so I do not need any other info for types. Otherwise I would need a switch
            return(new MyBaseMsg(msgType, eventType, msg.Priority)
            {
                ReturnCode = msg.ReturnCode,
                StringPayload = msg.StringPayload,
                ReturnStatus = msg.ReturnStatus
            });
        }
        static public void SendMsg(MyMsgType myMsgType, string msgValue, AudioProgressCommunicationDataType datatype = AudioProgressCommunicationDataType.UNKNOWN)
        {
            string sendString = msgValue;

            byte[]         sarr = System.Text.Encoding.Default.GetBytes(sendString);
            int            len  = sarr.Length;
            COPYDATASTRUCT cds;

            cds.dwData = (IntPtr)datatype;
            cds.cbData = len + 1;
            cds.lpData = sendString;
            //if ((int)MainWindow.CurMainWindowInstence.AudioProcess.MainWindowHandle == 0) throw new Exception("没找到音频进程");
            //SendMessage(MainWindow.CurMainWindowInstence.AudioProcess.MainWindowHandle, WM_COPYDATA, (int)myMsgType, ref cds);
        }
 static public void SendMsg(MyMsgType myMsgType, string msgValue, AudioProgressCommunicationDataType datatype = AudioProgressCommunicationDataType.UNKNOWN)
 {
     string sendString = msgValue;
     //byte[] sarr = System.Text.Encoding.Default.GetBytes(sendString);
     //int len = sarr.Length;
     //COPYDATASTRUCT cds;
     //cds.dwData = (IntPtr)datatype;
     //cds.cbData = len + 1;
     //cds.lpData = sendString;
     //if ((int)MainWindow.CurMainWindowInstence.AudioProcess.MainWindowHandle == 0) MessageBox.Show("没找到音频进程");
     //SendMessage(MainWindow.CurMainWindowInstence.AudioProcess.MainWindowHandle, WM_COPYDATA, (int)myMsgType, ref cds);
     //if (MainWindow.CurMainWindowInstence.AudioProcess.HasExited) MessageBox.Show("没找到音频进程");
     //PostThreadMessage(MainWindow.CurMainWindowInstence.AudioProcess.Threads[0].Id, WM_COPYDATA, IntPtr.Zero, IntPtr.Zero);
 }
Ejemplo n.º 4
0
 public void SendMessageToAllClients(MessageBase msg, MyMsgType type)
 {
     NetworkServer.SendToAll((short)type, msg);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Base response type for strong type check on enums
 /// </summary>
 /// <param name="msgType">The return message type</param>
 /// <param name="msg">
 /// The paired msg for this response which transmits the UID for correlation
 /// </param>
 /// <param name="code">The return code</param>
 /// <param name="status">The return string</param>
 public MyBaseResponse(MyMsgType msgType, ISpEventMessage msg, MyReturnCode code, string status)
     : base(new SpEnumToInt(msgType), msg, new SpEnumToInt(code), status)
 {
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Constructor for Normal Priority messages
 /// </summary>
 /// <param name="typeId">The type id to cast to derived for payload retrieval</param>
 /// <param name="eventId">The event identifier</param>
 public MyBaseMsg(MyMsgType msgType, MyEventType eventId)
     : this(msgType, eventId, SpEventPriority.Normal)
 {
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="type">The type id to cast to derived for payload retrieval</param>
 /// <param name="eventId">The event identifier</param>
 /// <param name="priority">The priority of the message</param>
 public MyBaseMsg(MyMsgType msgType, MyEventType eventType, SpEventPriority priority)
     : base(new SpEnumToInt(msgType), new SpEnumToInt(eventType), priority)
 {
 }
Ejemplo n.º 8
0
 public void SendMessage(MessageBase msg, MyMsgType type)
 {
     _CurrentClient.Send((short)type, msg);
 }