Exemplo n.º 1
0
        /// <summary>
        /// NetworkChannel 객체를 생성합니다.
        /// name은 이전에 생성된 NetworkChannel과 동일한 문자열을 사용할 수 없습니다.
        /// </summary>
        /// <param name="name">생성할 NetworkChannel의 고유한 이름.</param>
        /// <returns>생성된 NetworkChannel 객체</returns>
        public static NetworkChannel CreateChannel(String name)
        {
            lock (_channels)
            {
                NetworkChannel channel = _channels.Find(v => v.Name == name);
                if (channel != null)
                    throw new AegisException(ResultCode.AlreadyExistName, "Already exists same name.");

                channel = new NetworkChannel(name);
                _channels.Add(channel);

                return channel;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// NetworkChannel 객체를 생성합니다.
        /// name은 이전에 생성된 NetworkChannel과 동일한 문자열을 사용할 수 없습니다.
        /// </summary>
        /// <param name="name">생성할 NetworkChannel의 고유한 이름.</param>
        /// <param name="sessionGenerator">Session 객체를 생성할 핸들러. null이면 기본 Session 객체가 생성됩니다.</param>
        /// <returns>생성된 NetworkChannel 객체</returns>
        public static NetworkChannel CreateChannel(string name, SessionGenerateHandler sessionGenerator)
        {
            lock (Channels)
            {
                if (Channels.Exists(name))
                    throw new AegisException(AegisResult.AlreadyExistName, "'{0}' is already exists channel name.", name);

                NetworkChannel channel = new NetworkChannel(name);
                if (sessionGenerator == null)
                    channel.SessionGenerator = delegate { return GenerateSession("Aegis.Network.Session"); };
                else
                    channel.SessionGenerator = sessionGenerator;
                Channels.Add(name, channel);

                return channel;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// TreeNode에 정의된 데이터를 기준으로 NetworkChannel 객체를 생성합니다.
        /// TreeNode에는 name, sessionClass, maxSessionPoolCount, listenIpAddress, listenPortNo가 정의되어있어야 합니다.
        /// </summary>
        /// <param name="node">생성할 NetworkChannel의 데이터가 정의된 TreeNode</param>
        /// <returns>생성된 NetworkChannel 객체</returns>
        public static NetworkChannel CreateChannelFromNode(TreeNode <string> node)
        {
            lock (Channels)
            {
                string channelName = node.GetValue("name").ToString();
                if (Channels.Exists(channelName))
                {
                    throw new AegisException(AegisResult.AlreadyExistName, "'{0}' is already exists channel name.", node.Name);
                }


                NetworkChannel channel = new NetworkChannel(channelName);
                channel._configNode              = node;
                channel.SessionGenerator         = delegate { return(GenerateSession(node.GetValue("sessionClass"))); };
                channel.MaxSessionCount          = node.GetValue("maxSessionCount").ToInt32();
                channel.Acceptor.ListenIpAddress = node.GetValue("listenIpAddress");
                channel.Acceptor.ListenPortNo    = node.GetValue("listenPortNo").ToInt32();
                Channels.Add(channelName, channel);

                return(channel);
            }
        }
Exemplo n.º 4
0
 internal Acceptor(NetworkChannel networkChannel)
 {
     _networkChannel = networkChannel;
 }
Exemplo n.º 5
0
 internal Acceptor(NetworkChannel networkChannel)
 {
     _networkChannel         = networkChannel;
     _eventAccept            = new SocketAsyncEventArgs();
     _eventAccept.Completed += OnAccepted;
 }
Exemplo n.º 6
0
 internal Acceptor(NetworkChannel networkChannel)
 {
     _networkChannel = networkChannel;
     _eventAccept = new SocketAsyncEventArgs();
     _eventAccept.Completed += OnAccepted;
 }
Exemplo n.º 7
0
        /// <summary>
        /// TreeNode에 정의된 데이터를 기준으로 NetworkChannel 객체를 생성합니다.
        /// TreeNode에는 name, sessionClass, maxSessionPoolCount, listenIpAddress, listenPortNo가 정의되어있어야 합니다.
        /// </summary>
        /// <param name="node">생성할 NetworkChannel의 데이터가 정의된 TreeNode</param>
        /// <returns>생성된 NetworkChannel 객체</returns>
        public static NetworkChannel CreateChannelFromNode(TreeNode<string> node)
        {
            lock (Channels)
            {
                string channelName = node.GetValue("name").ToString();
                if (Channels.Exists(channelName))
                    throw new AegisException(AegisResult.AlreadyExistName, "'{0}' is already exists channel name.", node.Name);

                NetworkChannel channel = new NetworkChannel(channelName);
                channel._configNode = node;
                channel.SessionGenerator = delegate { return GenerateSession(node.GetValue("sessionClass")); };
                channel.MaxSessionCount = node.GetValue("maxSessionCount").ToInt32();
                channel.Acceptor.ListenIpAddress = node.GetValue("listenIpAddress");
                channel.Acceptor.ListenPortNo = node.GetValue("listenPortNo").ToInt32();
                Channels.Add(channelName, channel);

                return channel;
            }
        }