Example #1
0
        public async void OnNewInputConnectionAsync(object sender, NewConnectionArgs e)
        {
            var newEntity = await Game.CreateEntityAsync();

            NewInputEntityCreated?.Invoke(this, new SharperEntityEventArgs(newEntity));
            await RegisterComponentAsync(new SharperInputComponent(newEntity, e.Connection));
        }
Example #2
0
        private void Listener_OnConnectionAccepted(object sender, NewConnectionArgs e)
        {
            Console.WriteLine("[TCPServer] New client connected");
            SimpleTcpClient newClient = new SimpleTcpClient(1024, e.Client);

            newClient.OnException       += NewClient_OnException;
            newClient.OnReceivedMessage += NewClient_OnReceivedMessage;
            newClient.OnDisconnect      += NewClient_OnDisconnect;
            newClient.Start();
            connectedClients.Add(newClient);
        }
Example #3
0
        private async void Listener_OnConnectionAccepted(object sender, NewConnectionArgs e)
        {
            Console.WriteLine("[TCPServer] New client connected");
            SimpleTcpClient newClient = new SimpleTcpClient(1024, e.Client);

            newClient.OnException       += NewClient_OnException;
            newClient.OnReceivedMessage += NewClient_OnReceivedMessage;
            newClient.Start();
            await newClient.SendAsync(Encoding.ASCII.GetBytes("Hello I'm your server :D"));

            connectedClients.Add(newClient);
        }