Ejemplo n.º 1
0
 public void TestHandler(UdpContext udpContext)
 {
     hello = udpContext.GetData <Hello>();
     if (hello.HelloString == "re")
     {
         UdpServerTest.ackNums++;
     }
 }
Ejemplo n.º 2
0
 public void OnReceiveData(UdpContext udpContext)
 {
     IntegrationTest.data[peer.ID] = udpContext.GetData <string>();
     if (IntegrationTest.data[peer.ID] is "test")
     {
         Interlocked.Increment(ref IntegrationTest.nums);
     }
 }
Ejemplo n.º 3
0
        public void OnReceiveData(UdpContext udpContext)
        {
            var d = udpContext.GetData <string>();

            if (d == "test")
            {
                Program.nums++;
            }
            Console.WriteLine("peer:" + d);
        }
Ejemplo n.º 4
0
        public static DataSlice FromBytes(Memory <byte> bytes, UdpContext context)
        {
            var slice = new DataSlice();
            var span  = bytes.Span;

            slice.Last      = MemoryMarshal.Read <bool>(span.Slice(0, 1));
            slice.Len       = MemoryMarshal.Read <int>(span.Slice(1, 4));
            slice.No        = MemoryMarshal.Read <long>(span.Slice(5, 8));
            slice.SessionId = MemoryMarshal.Read <Guid>(span.Slice(13, 16));
            slice.Slice     = bytes[29..];
 public async void StreamHandShakeHandler(UdpContext context)
 {
     await peer.StreamTransferRequested(context.GetData <BasicFileInfo>());
 }
 public void StreamHandShakeCallbackHandler(UdpContext context)
 {
     peer.OnStreamHandshakeResult(context);
 }
 public void StartPunchingHandler(UdpContext context)
 {
     peer.StartHolePunching();
     _logger.LogInformation("punching started");
     context.Dispose();
 }
 public void PunchingDataHandler(UdpContext context)
 {
     _logger.LogInformation($"peer {peer.OuterEp?.ToIPEP()} punch data received");
     peer.PunchDataReceived(context.RemoteEndPoint);
     context.Dispose();
 }
 public void MTUHandler(UdpContext udpContext)
 {
     peer.RemoteBufferLen = udpContext.GetData <int>();
 }
Ejemplo n.º 10
0
 public void PingHandeler(UdpContext context)
 {
     peer.ResetPingCount();
     context.Dispose();
 }
Ejemplo n.º 11
0
 public async void FileDataHandler(UdpContext context)
 {
     await peer.FileDataReceived(DataSlice.FromBytes(context.Data, context));
 }
Ejemplo n.º 12
0
 public async void ConnectionRequestedHandler(UdpContext context)
 {
     _logger.LogInformation("received connection request!");
     await peer.OnConnectionRequested(context.GetData <PeerInfo>() !);
 }
Ejemplo n.º 13
0
 public void ConnectionRequestCallbackHandler(UdpContext context)
 {
     peer.OnConnectionCallback(context.GetData <bool>());
     _logger.LogInformation("received connection request callback!");
 }
Ejemplo n.º 14
0
 public void ConnectedDataHandler(UdpContext context)
 {
     _logger.LogInformation($"peer {peer.OuterEp?.ToIPEP()} connect data received");
     peer.PeerConnectedReceived();
     context.Dispose();
 }
Ejemplo n.º 15
0
 public void ChatMsgHandler(UdpContext udpContext)
 {
     OnChatMsgReceived?.Invoke(this, udpContext.GetData <string>());
 }