Beispiel #1
0
        /// <summary>
        /// za 종료
        /// </summary>
        private void zaSessionClosed(zaSession session)
        {
            try
            {
                StringBuilder sb = new StringBuilder();
                //219ZA는 종료전 모든 유저의 디스커넥트 패킷을 보내온다.
                //이후 사용자들이 개발한 za는 그렇제 못하므로 za가 디스커넥트되면 로그인 유저목록을 클리어 해준다.
                for (int i = g_Config.LoggedInList.Count - 1; i >= 0; i--)
                {
                    if (g_Config.LoggedInList.ElementAt(i).Value.ServerID == session.ServerID)
                    {
                        sb.Clear();
                        PrintLogs(sb.AppendFormat("loginuser.destroy {0}", g_Config.LoggedInList.ElementAt(i).Key).ToString());
                        g_Config.LoggedInList.Remove(g_Config.LoggedInList.ElementAt(i).Key);
                    }
                }

                sb.Clear();
                PrintLogs(sb.AppendFormat("<ZA>AgentID={0} Disconnected", session.AgentID).ToString());
                g_Config.ZoneAgentList.Remove(session.ServerID);
                session.Dispose();
            }
            catch (Exception ex)
            {
                WriteLogs(string.Format("LoginServer.zaSessionClosed:{0}{1}", Environment.NewLine, ex));
            }
        }
Beispiel #2
0
 /// <summary>
 /// 새 존 에이전트 접속
 /// </summary>
 /// <param name="zAgent"></param>
 /// <param name="buffer"></param>
 private void NewZoneAgentConnected(zaSession zAgent, Byte[] buffer)
 {
     try
     {
         MSG_ZA2LS_CONNECT new_za = new MSG_ZA2LS_CONNECT();
         new_za.SetBuffer(buffer);
         if (!g_Config.ZoneAgentList.ContainsKey(new_za.byServerID))
         {
             //zone agent 정보 저장
             zAgent.ServerID = new_za.byServerID;
             zAgent.AgentID  = new_za.byAgentID;
             zAgent.IPadress = new_za.szIPAdress;
             zAgent.Port     = new_za.dwPort;
             g_Config.ZoneAgentList.Add(new_za.byServerID, zAgent);
             PrintLogs(string.Format("<ZA>Receive SID={0} AgentID={1} {2}:{3}", new_za.byServerID, new_za.byAgentID, new_za.szIPAdress, new_za.dwPort));
             //정상 등록되면 이벤트 등록
             zAgent.StatusUpdate  += zaStatusUpdate;
             zAgent.SessionClosed += zaSessionClosed;
         }
         else
         {
             //중복 ServerID의 에이전트는 등록 거부
             PrintLogs(string.Format("<ZA>Receive AgentID={0} Duplicate ServerID={1}", new_za.byAgentID, new_za.byServerID));
             PrintLogs(string.Format("<ZA>AgentID={0} Connection Rejected", new_za.byAgentID));
             zAgent.Dispose();
         }
     }
     catch (Exception ex)
     {
         WriteLogs(string.Format("LoginServer.NewZoneAgentConnected:{0}{1}{0}Buffer:{0}{2}", Environment.NewLine, ex, BitConverter.ToString(buffer).Replace("-", " ")));
     }
 }