Exemplo n.º 1
0
        private void OnServerAcceptorAccepted(object sender, SocketEventArgs e)
        {
            PreallocatedChannelData channelResources = GetChannelData();

            ISocketChannel channel = new ImmutableChannel(e.Socket, channelResources.Receiver, channelResources.Sender, channelResources.ReceiverArgs, channelResources.SenderWriter, channelResources);

            channel.Closed += OnChannelClosed;

            RaiseConnected(channel);

            channel.Start();
        }
        protected virtual void OnConnectSucceeded(object o, SocketEventArgs e)
        {
            AllocateCommunicationResources();

            ISocketChannel channel = new ImmutableChannel(e.Socket, receiver, sender, receiverArgs, senderWriter);

            channel.Closed += OnChannelClosed;

            RaiseConnected(channel);
            ChangeState(ChannelState.Connected);

            channel.Start();
        }
Exemplo n.º 3
0
 /// <summary>Constructor</summary>
 /// <param name="node1">節点1</param>
 /// <param name="node2">節点2</param>
 /// <param name="channel">流路</param>
 public NodeConnectionEventArgs(ImmutableNode node1, ImmutableNode node2, ImmutableChannel channel)
 {
     this.node1 = node1;
     this.node2 = node2;
     this.channel = channel;
 }
Exemplo n.º 4
0
 /// <summary>流路を返す</summary>
 /// <param name="channel">読み取り専用流路</param>
 /// <returns>流路</returns>
 private Channel getChannel(ImmutableChannel channel)
 {
     foreach (Channel cn in channels)
     {
         if (cn.Equals(channel)) return cn;
     }
     return null;
 }
Exemplo n.º 5
0
        /// <summary>節点を切断する</summary>
        /// <param name="channel">接点を接続している流路</param>
        /// <returns>切断成功の真偽</returns>
        public bool DisconnectNodes(ImmutableChannel channel)
        {
            Channel cn = getChannel(channel);
            if (cn == null) return false;

            ImmutableNode nd1 = cn.Node1;
            ImmutableNode nd2 = cn.Node2;

            //切断処理
            cn.Disconnect();
            channels.Remove(cn);
            //IDを詰める
            foreach (Channel cnl in channels)
            {
                if (cnl.ID == (channels.Count - 1)) cnl.ID = cn.ID;
            }

            //イベント通知
            if (NodeDisConnectEvent != null) NodeDisConnectEvent(this, new NodeConnectionEventArgs(nd1, nd2, cn));

            return true;
        }
Exemplo n.º 6
0
 /// <summary>流路を削除する</summary>
 /// <param name="channel">流路</param>
 internal void RemoveChannel(ImmutableChannel channel)
 {
     channels.Remove(channel);
 }
Exemplo n.º 7
0
 /// <summary>流路を追加する</summary>
 /// <param name="channel">流路</param>
 internal void AddChannel(ImmutableChannel channel)
 {
     channels.Add(channel);
 }
Exemplo n.º 8
0
 /// <summary>指定した流路を含むか否かを返す</summary>
 /// <param name="channel">流路</param>
 /// <returns>指定した流路を含む場合は真</returns>
 public bool ContainsChannel(ImmutableChannel channel)
 {
     return channels.Contains(channel);
 }