Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public async Task AcceptClients()
- {
- var listener = new TcpListener(IPAddress.Any, GlobalConst.LobbyServerPort);
- listener.Start();
- while (true) {
- if (listener.Pending()) {
- var client = await listener.AcceptTcpClientAsync();
- Console.WriteLine("Accepting conneciton {0}", client);
- ProcessClient(client);
- }
- }
- }
- public async Task ProcessClient(TcpClient client)
- {
- try {
- var stream = client.GetStream();
- var reader = new StreamReader(stream, Encoding);
- await Write(stream, "TASServer 91.0 Test 123");
- while (true) {
- var line = await reader.ReadLineAsync();
- Console.WriteLine(line);
- if (line != null && line.StartsWith("LOGIN")) {
- await Task.Run(async () => {
- Account acc;
- using (var db = new ZkDataContext()) {
- acc = Account.AccountVerify(db, "test", "test");
- }
- await Write(stream, "LOGINACCEPTED " + acc.Name);
- });
- }
- }
- } catch (Exception ex) {
- Console.WriteLine(ex.ToString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement