-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathProgram.cs
More file actions
63 lines (53 loc) · 1.74 KB
/
Program.cs
File metadata and controls
63 lines (53 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using QuickNet.Utilities;
using QuicNet;
using QuicNet.Connections;
using QuicNet.Context;
using QuicNet.Infrastructure;
using QuicNet.Infrastructure.Frames;
using QuicNet.Infrastructure.PacketProcessing;
using QuicNet.Infrastructure.Packets;
using QuicNet.Streams;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace QuickNet.Tests.ConsoleServer
{
class Program
{
/// <summary>
/// Fired when Client is connected
/// </summary>
/// <param name="connection">The new connection</param>
static void ClientConnected(QuicConnection connection)
{
Console.WriteLine("Client Connected");
connection.OnStreamOpened += StreamOpened;
}
static void StreamOpened(QuicStream stream)
{
Console.WriteLine("Stream Opened. StreamID[{0}]", stream.StreamId);
stream.OnStreamDataReceived += StreamDataReceived;
}
static void StreamDataReceived(QuicStream stream, byte[] data)
{
string decoded = Encoding.UTF8.GetString(data);
string response = "Response from server: " + decoded.ToUpperInvariant();
Console.WriteLine("Stream Data Received from StreamID[{0}]\r\n <-- {1}\r\n --> {2}\r\n",
stream.StreamId, decoded, response);
stream.Send(Encoding.UTF8.GetBytes(response));
}
static void Example()
{
QuicListener listener = new QuicListener(11000);
listener.OnClientConnected += ClientConnected;
listener.Start();
Console.ReadLine();
}
static void Main(string[] args)
{
Example();
return;
}
}
}