当前位置: 首页>>代码示例>>C#>>正文


C# IoSession.Write方法代码示例

本文整理汇总了C#中IoSession.Write方法的典型用法代码示例。如果您正苦于以下问题:C# IoSession.Write方法的具体用法?C# IoSession.Write怎么用?C# IoSession.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IoSession的用法示例。


在下文中一共展示了IoSession.Write方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MessageReceived

        /// <summary>
        /// If the message is 'quit', we exit by closing the session. Otherwise,
        /// we return the current date.
        /// </summary>
        public override void MessageReceived(IoSession session, Object message)
        {
            String str = message.ToString();

            // "Quit" ? let's get out ...
            if (str.Trim().Equals("quit", StringComparison.OrdinalIgnoreCase))
            {
                session.Close(true);
                return;
            }

            // Send the current date back to the client
            session.Write(DateTime.Now.ToString());
            Console.WriteLine("Message written...");
        }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:19,代码来源:TimeServerHandler.cs

示例2: MessageReceived

        public override void MessageReceived(IoSession session, Object message)
        {
            Console.WriteLine("Player-" + id + ": RCVD " + message);

            TennisBall ball = (TennisBall)message;

            // Stroke: TTL decreases and PING/PONG state changes.
            ball = ball.Stroke();

            if (ball.TTL > 0)
            {
                // If the ball is still alive, pass it back to peer.
                session.Write(ball);
            }
            else
            {
                // If the ball is dead, this player loses.
                Console.WriteLine("Player-" + id + ": LOSE");
                session.Close(true);
            }
        }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:21,代码来源:TennisPlayer.cs

示例3: DoFlush

        private void DoFlush(IoSession session, WriteOp op)
        {
            if (op != null && !op.IsExpired)
            {
                try
                {
                    long cnt = flushCounter.AtomicIncrementAndGet();
                    long now = new DateTime().CurrentTimeMillis();
                    if (now - lastLogTime.ReadFullFence() > 60000)
                    {
                        lastLogTime.WriteFullFence(now);
                        string log = String.Format("opQueueSize: {0}, session: {1}, couner: {2}", opQueue.Count, session.RemoteEndPoint.ToString(), cnt);
                        client.Log.Info(log);
                    }

                    var writeFuture = session.Write(op.Command);
                    writeFuture.Complete += (s, e) =>
                    {
                        if (e.Future.Done)
                        {
                            flushing.AtomicExchange(false);
                            flushingOp.AtomicExchange(null);
                        }
                        else
                        {
                            if (!IsClosed)
                            {
                                Thread.Sleep(client.Config.EndpointSessionWriteRetryDealyInMills);
                                DoFlush(e.Future.Session, op);
                            }
                        }
                    };
                }
                catch (Exception ex)
                {
                    client.Log.Error(ex);
                    flushing.AtomicExchange(false);
                    flushingOp.AtomicExchange(null);
                }
            }
            else
            {
                flushing.AtomicExchange(false);
                flushingOp.AtomicExchange(null);
            }
        }
开发者ID:sdgdsffdsfff,项目名称:hermes.net,代码行数:46,代码来源:EndpointSession.cs

示例4: Write

 private void Write(IoSession session, String s)
 {
     session.Write(IoBuffer.Wrap(Encoding.ASCII.GetBytes(s)));
 }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:4,代码来源:AbstractTrafficControlTest.cs

示例5: buttonConnect_Click

        private void buttonConnect_Click(object sender, EventArgs e)
        {
            String server = textBoxServer.Text;
            if (String.IsNullOrEmpty(server))
                return;

            if (checkBoxSSL.Checked)
            {
                if (!connector.FilterChain.Contains("ssl"))
                    connector.FilterChain.AddFirst("ssl", new SslFilter("TempCert", null));
            }
            else if (connector.FilterChain.Contains("ssl"))
            {
                connector.FilterChain.Remove("ssl");
            }

            IPEndPoint ep;
            String[] parts = server.Trim().Split(':');
            if (parts.Length > 0)
            {
                ep = new IPEndPoint(IPAddress.Parse(parts[0]), Int32.Parse(parts[1]));
            }
            else
            {
                ep = new IPEndPoint(IPAddress.Loopback, Int32.Parse(parts[0]));
            }

            IConnectFuture future = connector.Connect(ep).Await();

            if (future.Connected)
            {
                session = future.Session;
                session.Write("LOGIN " + textBoxUser.Text);
            }
            else
            {
                MessageBox.Show("Could not connect to " + server);
            }
        }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:39,代码来源:FormChat.cs

示例6: MessageReceived

            public override void MessageReceived(IoSession session, Object message)
            {
                IoBuffer rb = message as IoBuffer;
                if (rb == null)
                    return;

                // Write the received data back to remote peer
                IoBuffer wb = IoBuffer.Allocate(rb.Remaining);
                wb.Put(rb);
                wb.Flip();
                session.Write(wb);
            }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:12,代码来源:AbstractBindTest.cs


注:本文中的IoSession.Write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。