Exemplo n.º 1
0
        public void OnTransportRead(IKcpSession session, ref WrappedReader reader, WrappedArgs args)
        {
            int length = (int)reader.Length;
            var buffer = reader.ReadBuffer(length);

            //string str = System.Text.Encoding.UTF8.GetString(buffer.FirstSpan);
            //Console.WriteLine($"频道:{session.Conv},收到消息:{str}" );
        }
Exemplo n.º 2
0
        public override void OnSessionClosed(IKcpSession session)
        {
            if (!this.sessions.ContainsKey(session.Conv))
            {
                return;
            }

            this.sessions.Remove(session.Conv);
        }
Exemplo n.º 3
0
        protected void SendExceptionTo(IKcpSession session, Exception ex)
        {
            var kcpSession = session as KcpSession;

            if (kcpSession == null)
            {
                throw new Exception("Unknown session type");
            }

            kcpSession.OnUdpMessageException(ex);
        }
Exemplo n.º 4
0
        protected void SendUdpMessageTo(IKcpSession session, ref ReadOnlySequence <byte> buffer)
        {
            var kcpSession = session as KcpSession;

            if (kcpSession == null)
            {
                throw new Exception("Unknown session type");
            }

            kcpSession.InputUdpMessage(ref buffer);
        }
Exemplo n.º 5
0
        public override void OnTransportActive(IKcpSession session)
        {
            base.OnTransportActive(session);

            M.sessions.Add(session);

            //int count = 10;
            //for (int i = 0; i < count; i++)
            //{
            //    byte[] bytes = System.Text.Encoding.UTF8.GetBytes("kcp>>>>>>>>>>nihao_" + i.ToString());
            //    session.SafeSendAsync(bytes);
            //}

            //for (int i = 0; i < count; i++)
            //{
            //    byte[] bytes = System.Text.Encoding.UTF8.GetBytes("udp>>>>>>>>>>nihao_" + i.ToString());
            //    session.UnsafeSendAsync(Program.s_address, bytes);
            //}
        }
Exemplo n.º 6
0
 public abstract void OnSessionClosed(IKcpSession session);
Exemplo n.º 7
0
 public void OnTransportWrite(IKcpSession session, ref WrappedWriter writer, WrappedArgs args)
 {
     byte[] bytes = args.Value as byte[];
     //Console.WriteLine("kcp pipeline写入数据>>" + bytes.Length);
     writer.Write(bytes);
 }
Exemplo n.º 8
0
 public void OnTransportException(IKcpSession session, Exception ex)
 {
     Console.WriteLine(">>>>>>>>>>>>>>>>>" + ex.ToString());
 }
Exemplo n.º 9
0
 public void OnTransportInactive(IKcpSession session)
 {
 }
Exemplo n.º 10
0
 public virtual void OnTransportActive(IKcpSession session)
 {
     Console.WriteLine($"{filterName}>>>>>OnTransportActive");
 }