This class is passed into the MsgHandler delegate, providing the message received.
Наследование: System.EventArgs
Пример #1
0
    async void msgSystMsg(object caller, NATS.Client.MsgHandlerEventArgs income)
    {
        Debug.Log(caller);
        var inst_msg = RoomMsg.Parser.ParseFrom(income.Message.Data);

        Debug.Log(inst_msg.Message);
        Debug.Log(inst_msg.MsgType.ToString());
        if (inst_msg.MsgType == RoomMsg.Types.MsgType.SystemInfo)
        {
            if (inst_msg.Message == "Dueler:GameSet:Ready" && this.Connecter.IsHost)
            {
                isReady = true;
                this.DuelerStatus.text = "Ready!";
            }
            else if (inst_msg.Message == "Host:GameSet:Ready" && !this.Connecter.IsHost)
            {
                isReady = true;
                this.HostStatus.text = "Ready";
            }
            else if (inst_msg.Message.Contains("UPDATE_ROOM:pw::") && !this.Connecter.IsHost)
            {
                string _pw      = inst_msg.Message.Replace("UPDATE_ROOM:pw::", "");
                var    roomInfo = await this.Connecter.GetRoom(this.Connecter.CurrentRoom.Key, _pw, !this.Connecter.IsWatcher);

                updatePanel_init(roomInfo);
            }
            else if (inst_msg.Message.Contains("CardChange::"))
            {
                OnConnecterUpdate_CardChange(inst_msg);
            }
        }
    }
Пример #2
0
        private void ReactiveHandler(object sender, Original.MsgHandlerEventArgs e)
        {
            bool match = this._ctx.DeserializeAndCheckSimpleJson(e.Message.Data, this._n);

            Debug.Assert(match);
            ++_n;
            if (this._n >= this._ctx.LoopCount)
            {
                this._cde.Signal();
            }
        }
Пример #3
0
    public void EventGenMessage(NATS.Client.MsgHandlerEventArgs income)
    {
        var        msg   = RoomMsg.Parser.ParseFrom(income.Message.Data);
        GameObject title = (GameObject)Instantiate(NamePref, ChatPanel.transform);

        title.GetComponent <Text>().text =
            msg.FmName +
            "\t< id : " + msg.FromId.ToString() + ">";

        if (msg.MsgType == RoomMsg.Types.MsgType.UserText)
        {
            GameObject info = (GameObject)Instantiate(DespPref, ChatPanel.transform);
            info.GetComponent <Text>().text = msg.Message;
        }
        return;
    }
Пример #4
0
        private void ExpectedReplyHandler(object sender, MsgHandlerEventArgs args)
        {
            if ("bar".Equals(args.Message.Reply) == false)
                Assert.Fail("Expected \"bar\", received: " + args.Message);

            lock(mu)
            {
                received = true;
                Monitor.Pulse(mu);
            }
        }
Пример #5
0
        private void CheckReceivedAndValidHandler(object sender, MsgHandlerEventArgs args)
        {
            System.Console.WriteLine("Received msg.");

            if (compare(args.Message.Data, omsg) == false)
                Assert.Fail("Messages are not equal.");

            if (args.Message.ArrivalSubcription != asyncSub)
                Assert.Fail("Subscriptions do not match.");

            lock (mu)
            {
                received = true;
                Monitor.Pulse(mu);
            }
        }
Пример #6
0
            public void msgHandlerToEncoderHandler(Object sender, MsgHandlerEventArgs args)
            {
                try
                {
                    byte[] data = args.msg != null ? args.msg.Data : null;
                    ehev.obj = c.onDeserialize(data);
                }
                catch (Exception ex)
                {
                    c.lastEx = new NATSException("Unable to deserialize message.", ex);
                    return;
                }

                ehev.subject = args.msg.Subject;
                ehev.reply = args.msg.Reply;
                ehev.msg = args.msg;

                try
                {
                    mh(this, ehev);
                }
                catch (Exception)
                {
                    /* ignore user thrown exceptions */
                }
            }
Пример #7
0
 private void incrReceivedMessageHandler(object sender,
     MsgHandlerEventArgs args)
 {
     Interlocked.Increment(ref received);
 }
Пример #8
0
 private void incrReceivedMessageHandler(object sender,
     MsgHandlerEventArgs args)
 {
     System.Console.WriteLine("Received message on subject {0}.",
         args.Message.Subject);
     Interlocked.Increment(ref received);
 }