Exemplo n.º 1
0
            public CKey Connect(TPeerCnt PeerNum_, string DataPath_, CNamePort MasterNamePort_)
            {
                var FullPath = Path.GetFullPath(DataPath_);

                var FileName = FullPath + "Data_" + PeerNum_.ToString() + ".bin";

                _Servers.AddAt((Int32)PeerNum_, new _SServer(_PeerCounter, MasterNamePort_, FileName));
                if (!_Connect(PeerNum_))
                {
                    return(new CKey());
                }

                return(new CKey(PeerNum_, _PeerCounter++));
            }
Exemplo n.º 2
0
            public bool Login(TPeerCnt PeerNum_, string DataPath_, CNamePort HubNamePort_, string ID_, TUID SubUID_, CStream Stream_)
            {
                var itClient      = _Clients.AddAt((Int32)PeerNum_, new _SClient(PeerNum_, DataPath_, HubNamePort_, SubUID_, Stream_));
                var NodeToConnect = itClient.Data.GetNodeToConnect(ID_);

                if (NodeToConnect == _ENode.Null)
                {
                    _Clients.Remove(itClient);
                    return(false);
                }

                _ConnectToUpper(PeerNum_, NodeToConnect);

                return(true);
            }
Exemplo n.º 3
0
            protected void _Link(CKey Key_, Socket Socket_, SocketAsyncEventArgs Event_)
            {
                Event_.UserToken = Key_;
                var NamePort = new CNamePort((IPEndPoint)Event_.RemoteEndPoint);

                _Peers.AddAt((Int32)Key_.PeerNum, new CPeer(_HeaderSize, _HBRcvDelay, _HBSndDelay, Socket_, Key_, NamePort));

                try
                {
                    _LinkFunc(Key_, NamePort);
                }
                catch (Exception Exception_)
                {
                    throw new ExceptionNet(ENetRet.ExceptionExternal, Exception_);
                }
            }
Exemplo n.º 4
0
 public CAgent(
     string FileName_, string DataPath_,
     CNamePort MasterNamePort_, TLinkFunc LinkFunc_, TLinkFailFunc LinkFailFunc_, TUnLinkFunc UnLinkFunc_,
     TDataFunc DataFunc_) :
     base(FileName_, DataPath_)
 {
     _MasterNamePort = MasterNamePort_;
     _LinkFunc       = LinkFunc_;
     _LinkFailFunc   = LinkFailFunc_;
     _UnLinkFunc     = UnLinkFunc_;
     _DataFunc       = DataFunc_;
     _NetM           = new net.CClient(
         _LinkM, _LinkFailM, _UnLinkM, _RecvM,
         false, 1024000, 1024000,
         TimeSpan.FromMilliseconds(30000), TimeSpan.FromMilliseconds(20000), 60);
 }
Exemplo n.º 5
0
            void _LinkA(CKey Key_, CNamePort NamePort_)
            {
                switch (_Clients[(Int32)Key_.PeerNum].CaProto)
                {
                case EProto.CaCreate:
                    _NetA.Send(Key_.PeerNum, new SHeader(_Clients[(Int32)Key_.PeerNum].CaProto), new SCaCreate(_Clients[(Int32)Key_.PeerNum].ID, _Clients[(Int32)Key_.PeerNum].Nick));
                    break;

                case EProto.CaLogin:
                    _NetA.Send(Key_.PeerNum, new SHeader(_Clients[(Int32)Key_.PeerNum].CaProto), new SCaLogin(_Clients[(Int32)Key_.PeerNum].UID, _Clients[(Int32)Key_.PeerNum].ID));
                    break;

                case EProto.CaCheck:
                    _NetA.Send(Key_.PeerNum, new SHeader(_Clients[(Int32)Key_.PeerNum].CaProto), new SCaCheck(_Clients[(Int32)Key_.PeerNum].ID));
                    break;
                }
            }
Exemplo n.º 6
0
            public CPeer(Int32 HeaderSize_, TimeSpan HBRcvDelay_, TimeSpan HBSndDelay_, Socket Socket_, CKey Key_, CNamePort NamePort_)
            {
                _RecvBuf    = new Byte[40960];
                _HeaderSize = HeaderSize_;

                if (HBRcvDelay_.TotalSeconds > 0.0)
                {
                    _HBRcvPeriod = new CPeriod(HBRcvDelay_ + TimeSpan.FromSeconds(3));
                    _HBRcvPeriod.NextLoose();
                }

                if (HBSndDelay_.TotalSeconds > 0.0)
                {
                    _HBSndPeriod = new CPeriod(HBSndDelay_);
                }

                _Socket   = Socket_;
                _Key      = Key_;
                _NamePort = NamePort_;
            }
Exemplo n.º 7
0
            public CKey Connect(CNamePort NamePort_, TPeerCnt PeerNum_)
            {
                try
                {
                    var itPeerConnecting = _PeersAndConnectings.AddAt((Int32)PeerNum_, _NewKey(PeerNum_));
                    try
                    {
                        _Connectings.AddAt((Int32)PeerNum_, NamePort_);
                    }
                    catch
                    {
                        _PeersAndConnectings.Remove(itPeerConnecting);
                        throw;
                    }

                    return(itPeerConnecting.Data);
                }
                catch
                {
                    return(null);
                }
            }
Exemplo n.º 8
0
 void _LinkS(CKey Key_, CNamePort NamePort_)
 {
     _NetS.Send(Key_.PeerNum, new SHeader(EProto.CsConnect), new SCsConnect(_Servers[(Int32)Key_.PeerNum].PrevConnectNamePort));
     _Servers[(Int32)Key_.PeerNum].PrevConnectNamePort = NamePort_;
 }
Exemplo n.º 9
0
 void _LinkS(CKey Key_, CNamePort NamePort_)
 {
     _NetB.Send(Key_.PeerNum, new SHeader(EProto.CsLogin), new SCsLogin(_Data.Data.Version));
     _LinkFunc(Key_, NamePort_);
 }
Exemplo n.º 10
0
 void LinkSoft(CKey Key_, CNamePort NamePort_)
 {
     _Log("LinkFuncSoft");
 }
Exemplo n.º 11
0
 public CKey Connect(TPeerCnt PeerNum_, string DataPath_, CNamePort MasterNamePort_)
 {
     return(_NetB.Connect(PeerNum_, DataPath_, MasterNamePort_));
 }
Exemplo n.º 12
0
 public CKey Connect(string DataPath_, CNamePort MasterNamePort_)
 {
     return(_NetB.Connect(DataPath_, MasterNamePort_));
 }
Exemplo n.º 13
0
 static void Link(CKey Key_, CNamePort NamePort_)
 {
     Clients.Add(Key_, new SData());
     Console.WriteLine("Link:" + Key_.PeerNum);
 }
Exemplo n.º 14
0
 public CKey Connect(string DataPath_, CNamePort MasterNamePort_)
 {
     return(Connect((TPeerCnt)_Servers.NewIndex, DataPath_, MasterNamePort_));
 }
Exemplo n.º 15
0
 public void Create(TPeerCnt PeerNum_, string DataPath_, CNamePort AuthNamePort_, string ID_, string Nick_, TUID SubUID_, CStream Stream_)
 {
     _Clients.AddAt((Int32)PeerNum_, new _SClient(PeerNum_, DataPath_, AuthNamePort_, ID_, Nick_, SubUID_, Stream_));
     _ConnectToUpper(PeerNum_, _ENode.Auth);
 }
Exemplo n.º 16
0
 public bool Connect(string DataPath_, CNamePort AllocatorNamePort_)
 {
     return(Connect((TPeerCnt)_Servers.NewIndex, DataPath_, AllocatorNamePort_));
 }
Exemplo n.º 17
0
 void _LinkM(CKey Key_, CNamePort NamePort_)
 {
     _NetM.Send(Key_.PeerNum, new SHeader(EProto.AmLogin), new SAmLogin(_ID, _PW, _Data.Data.Version));
     _LinkFunc(Key_, NamePort_);
 }
Exemplo n.º 18
0
 void _Link(CKey Key_, CNamePort NamePort_)
 {
     _Servers[(Int32)Key_.PeerNum].Key = Key_;
 }
Exemplo n.º 19
0
 static void Link(CKey Key_, CNamePort NamePort_)
 {
     Console.WriteLine("Link:" + Key_.PeerNum.ToString());
 }
Exemplo n.º 20
0
 void Link(CKey Key_, CNamePort NamePort_)
 {
 }
Exemplo n.º 21
0
 static void Link(CKey Key_, CNamePort NamePort_ )
 {
     _Key = Key_;
     Console.WriteLine("Link:" + Key_.PeerNum);
 }
Exemplo n.º 22
0
            void _LinkS(CKey Key_, CNamePort NamePort_)
            {
                var Client = _Clients[(Int32)Key_.PeerNum];

                _NetS.Send(Key_.PeerNum, new SHeader(EProto.CsLogin), new SCsLogin(Client.UID, Client.ID, Client.SubUID, Client.SessionCode, _Version, Client.IsCreate(), Client.Stream));
            }
Exemplo n.º 23
0
 void _LinkCallback(CKey Key_, CNamePort NamePort_)
 {
     _ConnectTimeOut.Remove((Int32)Key_.PeerNum);
     _LinkFunc(Key_, NamePort_);
 }
Exemplo n.º 24
0
 public void Create(string DataPath_, CNamePort AuthNamePort_, string ID_, string Nick_, TUID SubUID_, CStream Stream_)
 {
     Create((TPeerCnt)_Clients.NewIndex, DataPath_, AuthNamePort_, ID_, Nick_, SubUID_, Stream_);
 }
Exemplo n.º 25
0
 void _LinkS(CKey Key_, CNamePort NamePort_)
 {
     _ServerKey = Key_;
     _LinkFunc(Key_, NamePort_);
     _Net.Send(Key_.PeerNum, new SCsHeader(ECsProto.Login, new List <SKey>()), _LoginInfo);
 }
Exemplo n.º 26
0
 public bool Login(string DataPath_, CNamePort AuthNamePort_, string ID_, TUID SubUID_, CStream Stream_)
 {
     return(Login((TPeerCnt)_Clients.NewIndex, DataPath_, AuthNamePort_, ID_, SubUID_, Stream_));
 }
Exemplo n.º 27
0
                public bool HaveBeenLinked = false; // 한번이라도 IsLinked 가 true 인 적이 있었는가? (한번 IsLinked 가 true가 되면 _SPeerExt가 제거되기 전까지 연결된 상태이므로 외부에서의 Linked)

                public _SPeerExt(CKey Key_, CNamePort NamePort_) :
                    base(Key_)
                {
                    NamePort = NamePort_;
                }
Exemplo n.º 28
0
 static void LinkSoft(CKey Key_, CNamePort NamePort_)
 {
     Console.WriteLine("LinkSoft:" + Key_.PeerNum);
 }
Exemplo n.º 29
0
 public CKey Connect(CNamePort NamePort_)
 {
     return(Connect(NamePort_, (TPeerCnt)_PeersExt.NewIndex));
 }