public bool Link(TPeerCnt PeerNum_, SIPPort IPPort_, Int32 ConnectTimeOut_) { try { var Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); Socket.NoDelay = _NoDelay; SKey Key = _PeerMgr.Link(PeerNum_); if (Key == null) { return(false); } if (!_Peers[Key.PeerNum].Link(Socket, IPPort_, Key, _Worker, ConnectTimeOut_)) { _PeerMgr.UnLink(Key.PeerNum); return(false); } return(true); } catch { return(false); } }
public SKey(SKey k1) { m_key[0] = k1.m_key[0]; m_key[1] = k1.m_key[1]; m_key[2] = k1.m_key[2]; m_key[3] = k1.m_key[3]; }
TPeerCnt _UnLinkCore() { if (_Key == null) { return(TPeerCnt.MaxValue); } if (_Socket != null) { _Socket.Close(); _Socket = null; } _RecvHeader = null; _StreamSndTail = 0; _RecvPacketSeq = 0; _SendPacketSeq = 0; _StreamRcv.Clear(); _StreamSnd.Clear(); _LongIP = 0; _Sending = false; _Connected = false; _ConnectTime = 0; _ConnectTimeOut = 0; _Connecting = false; var PeerNum = _Key.PeerNum; _Key = null; return(PeerNum); }
public void Linked(SKey Key_) { if (!_IsValid(Key_)) { return; } _Linked(); }
public void LinkFailed(SKey Key_) { if (!Key_.Equals(_Key)) { return; } _LinkFailed(); }
public void UnLink(SKey Key_, Enum NetState_) // Socket 콜백 { if (!_IsValid(Key_)) { return; } _UnLink(NetState_); }
public void Recved(SKey Key_) // Socket 콜백 처리 { if (!_IsValid(Key_)) { return; } _Recved(); }
public void Sended(SKey Key_) { if (!_IsValid(Key_)) { return; } if (_Sended()) { if (_StreamSnd.Size > 0) { _SendCore(); } } }
public void GameProtoNetSc(SKey Key_, CStream Stream_) { var Proto = new SGameProtoNetSc(); Proto.Push(Stream_); if (_Auto) { // _Log("ScFail CsProto:" + Proto.CsProto.ToString() + " ErrorNo:" + Proto.ErrorNo + " Msg:" + Proto.Msg); } else { _Log("GameProtoNetSc"); // _Log("ScFail CsProto:" + Proto.CsProto.ToString() + " ErrorNo:" + Proto.ErrorNo + " Msg:" + Proto.Msg); } }
public SKey Link(TPeerCnt PeerNum_) { SKey Key = new SKey(PeerNum_, _Counter); try { _PeerList.Add(PeerNum_, Key); Key.PeerNum = PeerNum_; ++_Counter; return(Key); } catch { return(null); } }
// 유저 호출 public bool Link(Socket Socket_, SIPPort IPPort_, SKey Key_, TEventHandler RecvEventHandler_, Int32 ConnectTimeOut_) { if (_Socket != null) { return(false); } _RecvEvent = new SocketAsyncEventArgs(); _RecvEvent.Completed += new EventHandler <SocketAsyncEventArgs>(RecvEventHandler_); _SendEvent = new SocketAsyncEventArgs(); _SendEvent.Completed += new EventHandler <SocketAsyncEventArgs>(RecvEventHandler_); _Socket = Socket_; _RecvEvent.UserToken = Key_; _RecvEvent.RemoteEndPoint = IPPort_.EndPoint; _Key = Key_; _LongIP = IPPort_.IP; try { if (!_Socket.ConnectAsync(_RecvEvent)) // _Worker 로 통보받을 필요 없음. { _HBRcvPeriod.NextLoose(); return(_Linked()); } else { _Connecting = true; _ConnectTime = Environment.TickCount; _ConnectTimeOut = ConnectTimeOut_; } } catch { _LinkFailed(); return(false); } return(true); }
public StandFunBar() { float left = 0; var keyString = functionKeys.Split(' '); float width = (float)(14.5 / 16.0); for (int i = 0; i < keyString.Length; i++) { string k = keyString[i]; if (i < keyString.Length - 4) { SKey key = new SKey(k, new System.Drawing.RectangleF(left, 0, width, 1)) { Text = keyString[i], type = "control", value = keyString[i] }; left += width; key.Click += (m, n) => { KeyClick(key.GetKey()); }; keys.Add(key); } else { SKey key = new SKey(k, new System.Drawing.RectangleF(left, 0, 1, 1)) { Text = keyString[i], type = "control", value = keyString[i] }; left += 1; key.Click += (m, n) => { KeyClick(key.GetKey()); }; keys.Add(key); } } PreparParams(); }
public void Set(SKey Obj_) { PeerNum = Obj_.PeerNum; PeerCounter = Obj_.PeerCounter; }
public SUdNewChild(SUdNewChild Obj_) { ClientBindNamePortPub = Obj_.ClientBindNamePortPub; SessionCode = Obj_.SessionCode; NewChildKey = Obj_.NewChildKey; }
public SUdNewChild(SNamePort ClientBindNamePortPub_, TSessionCode SessionCode_, SKey NewChildKey_) { ClientBindNamePortPub = ClientBindNamePortPub_; SessionCode = SessionCode_; NewChildKey = NewChildKey_; }
public SDuNewChild(SDuNewChild Obj_) { NewChildKey = Obj_.NewChildKey; SessionCode = Obj_.SessionCode; }
public SReLinkCs(SKey ServerExtKey_, TProtoSeq ClientProtoSeqMustRecv_) { ServerExtKey = ServerExtKey_; ClientProtoSeqMustRecv = ClientProtoSeqMustRecv_; }
public SDuNewChild(SKey NewChildKey_, TSessionCode SessionCode_) { NewChildKey = NewChildKey_; SessionCode = SessionCode_; }
public SDuNewChildFail(SDuNewChildFail Obj_) { NewChildKey = Obj_.NewChildKey; }
public SDuNewChildFail(SKey NewChildKey_) { NewChildKey = NewChildKey_; }
int _StreamSndTail = 0; // 전 패킷에 붙여보내기 위한 인덱스 bool _IsValid(SKey Key_) { return(_Key != null && _Key.Equals(Key_)); }
public MessBase(MessType type) : this() { Type = type; Key = null; }
public SKey(SKey Obj_) { PeerNum = Obj_.PeerNum; PeerCounter = Obj_.PeerCounter; }
public MessBase(MessType type, ProcType proc, MarketType market = MarketType.Empty, string pair = null, SysType sys_type = SysType.Empty) : this() { Type = type; Key = new SKey(proc, market, pair, sys_type); }
public CKey(SKey Key_) : base(Key_) { }
public SLinkSc(SKey ServerExtKey_) { ServerExtKey = ServerExtKey_; }
public SLinkSc(SLinkSc Obj_) { ServerExtKey = Obj_.ServerExtKey; }
public SReLinkCs(SReLinkCs Obj_) { ServerExtKey = Obj_.ServerExtKey; ClientProtoSeqMustRecv = Obj_.ClientProtoSeqMustRecv; }