internal void Update(int elapsedTime) { LinkedListNode <P2pMember> node = _memberList.First; while (node != null) { P2pMember member = node.Value; node = node.Next; member.Update(elapsedTime); } }
/// <summary> /// 세션 아이디로 멤버를 구한다 /// </summary> /// <param name="sessionId">세션 아이디</param> /// <returns>찾은 멤버</returns> public P2pMember Find(ushort sessionId) { LinkedListNode <P2pMember> node = _memberList.First; while (node != null) { P2pMember member = node.Value; node = node.Next; if (member != null && member.SessionId == sessionId) { return(member); } } return(null); }
/// <summary> /// 세션 아이디로 세션이 있는지 확인 /// </summary> /// <param name="sessionId">세션 아이디</param> /// <returns>포함여부</returns> public bool Contains(ushort sessionId) { LinkedListNode <P2pMember> node = _memberList.First; while (node != null) { P2pMember member = node.Value; node = node.Next; if (member != null && member.SessionId == sessionId) { return(true); } } return(false); }
internal P2pMember Leave(ushort sessionId, ushort masterSessionId) { P2pMember member = Find(sessionId); if (member == null) { Logger.LogError($"Not exist P2p member : {sessionId}"); return(null); } _memberList.Remove(member); _masterSessionId = masterSessionId; Logger.LogInformation($"Leave p2p : {sessionId} Master : {masterSessionId}"); return(member); }
internal P2pMember Join(ISession session, ushort masterSessionId) { if (Contains(session.SessionId) == true) { Logger.LogError($"Already exist P2p member : {session.SessionId}"); return(null); } _masterSessionId = masterSessionId; P2pMember p2pMember = new P2pMember(this); p2pMember.SetSession(session); _memberList.AddLast(p2pMember); Logger.LogInformation($"Join p2p : {session.SessionId} Master : {masterSessionId}"); return(p2pMember); }