Exemple #1
0
        private void OnAccepted(Msg m)
        {
            // m의 소켓을 갖고 새로운 프로토콜을 만든다.

            var ma = (MsgAcceptedNode)m;
            var p  = new MsgPackProtocol(this, ma.Socket);

            logger.Debug($"Accepted. New:{p.ProtocolId}, Acceptor:{m.Protocol.ProtocolId}");

            using (var wlock = new WriteLock(rwLock))
            {
                protocols[p.ProtocolId] = p;
            }

            // 애플리케이션에 전달
            var msgApp = new MsgAccepted()
            {
                Protocol = p
            };

            Notify(msgApp);

            // 연결 해제 내가 받도록 설정
            p.Subscribe(this, (uint)MsgInternal.Disconnected, OnDisconnected);
            p.BeginRecvInternalFromNode();
        }
Exemple #2
0
        public Result Connect(string address, object o, Action <Msg> connected, Action <Msg> disconnected)
        {
            var c = new MsgPackProtocol(this);

            // subscribe : connected, disconnected

            logger.Debug($"Connecting. Address:{address}");

            using (var wlock = new WriteLock(rwLock))
            {
                protocols[c.ProtocolId] = c;
            }

            c.Subscribe(this, (uint)MsgInternal.Connected, OnConnected);
            c.Subscribe(this, (uint)MsgInternal.Disconnected, OnDisconnected);
            c.Subscribe(o, (uint)MsgInternal.Connected, connected);
            c.Subscribe(o, (uint)MsgInternal.Disconnected, disconnected);

            return(c.Connect(address));
        }
Exemple #3
0
 public MsgPackNode()
 {
     this.acceptor = new MsgPackProtocol(this);
 }