Esempio n. 1
0
        public static IPCMessage.IIPCMessage FromRawIPCMessage(RawIPCMessage rawmsg)
        {
            IPCMessage.IIPCMessage ret;
            switch (rawmsg.MessageName)
            {
            case "Chat":
                ret = new IPCMessage.ChatIPCMessage();
                break;

            case "ChannelList":
                ret = new IPCMessage.ChannelListIPCMessage();
                break;

            case "ChannelSelect":
                ret = new IPCMessage.ChannelSelectIPCMessage();
                break;

            case "CurrentChannel":
                ret = new IPCMessage.CurrentChannelIPCMessage();
                break;

            case "Time":
                ret = new IPCMessage.TimeIPCMessage();
                break;

            case "Close":
                ret = new IPCMessage.CloseIPCMessage();
                break;

            case "SetChatOpacity":
                ret = new IPCMessage.SetChatOpacityIPCMessage();
                break;

            case "Command":
                ret = new IPCMessage.CommandIPCMessage();
                break;

            default:
                throw new IPCMessage.IPCMessageDecodeException("不明なMessageNameです: " + rawmsg.ToString());
            }
            ret.Decode(rawmsg.Contents);
            return(ret);
        }
Esempio n. 2
0
        private void ipc_MessageReceived(IPC.IPCMessage.IIPCMessage message)
        {
            IPC.IPCMessage.ChannelListIPCMessage    chlistmsg = message as IPC.IPCMessage.ChannelListIPCMessage;
            IPC.IPCMessage.CurrentChannelIPCMessage curchmsg  = message as IPC.IPCMessage.CurrentChannelIPCMessage;
            IPC.IPCMessage.TimeIPCMessage           timemsg   = message as IPC.IPCMessage.TimeIPCMessage;

            if (chlistmsg != null)
            {
                //選択できるチャンネルリストを伝えるメッセージ
                channelList.Clear();
                channelList.AddRange(chlistmsg.ChannelList);
            }
            else if (curchmsg != null)
            {
                //現在のチャンネル・番組情報を伝えるメッセージ
                //NID,TSID,SIDがすべて同じならチャンネルは同じで変わってないと判定する
                if (this.currentChannel.Value == null || (this.currentChannel.Value.NetworkId != curchmsg.Channel.NetworkId ||
                                                          this.currentChannel.Value.TransportStreamId != curchmsg.Channel.TransportStreamId || this.currentChannel.Value.ServiceId != curchmsg.Channel.ServiceId))
                {
                    this.currentChannel.Value = curchmsg.Channel;
                }

                var currentChannel = ChannelList.Select((ch, idx) => new { Channel = ch, Index = idx }).FirstOrDefault((x) =>
                                                                                                                       curchmsg.Channel.NetworkId == x.Channel.NetworkId && curchmsg.Channel.TransportStreamId == x.Channel.TransportStreamId &&
                                                                                                                       curchmsg.Channel.ServiceId == x.Channel.ServiceId);

                //チャンネルリスト内に同じチャンネルがあればそれを今回のメッセージで得たインスタンスに置き換える
                if (currentChannel != null)
                {
                    this.channelList[currentChannel.Index] = this.currentChannel.Value;
                }

                this.currentEvent.Value = curchmsg.Event;
            }
            else if (timemsg != null)
            {
                //TOTを伝えるメッセージ
                //精度は1秒単位で値が変わるごとに来る
                currentTime.Value = timemsg.Time;
            }
        }