Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Lidgren.Network;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Tao.OpenGl;
- namespace Client
- {
- public class Client
- {
- public Graphics graphics;
- public NetClient netClient;
- public Client()
- {
- graphics = new Graphics();
- NetPeerConfiguration conf = new NetPeerConfiguration("2dgame");
- netClient = new NetClient(conf);
- netClient.Start();
- netClient.Connect("127.0.0.1", 666);
- while (netClient.ServerConnection == null) { }
- NetOutgoingMessage msg = netClient.CreateMessage();
- msg.Write((byte)0x01);
- msg.Write("Szymski");
- netClient.SendMessage(msg, NetDeliveryMethod.ReliableOrdered);
- while (true)
- {
- NetIncomingMessage m;
- while ((m = netClient.ReadMessage()) != null)
- {
- if (m.MessageType == NetIncomingMessageType.Data)
- {
- byte packetId = m.ReadByte();
- switch (packetId)
- {
- case 0x10:
- Console.WriteLine(m.ReadString());
- break;
- }
- }
- }
- graphics.window.DispatchEvents();
- Gl.glClearColor(0.2f, 0.2f, 0.2f, 1f);
- Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
- graphics.window.Display();
- }
- }
- #region Singleton
- private static Client instance;
- public static void CreateInstance()
- {
- instance = new Client();
- }
- public static Client Instance
- {
- get
- {
- if (instance == null)
- {
- instance = new Client();
- }
- return instance;
- }
- }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement