NetworkLevel2Connection connectiontoserver; // used by client //bool connectionopen = false; // used by client //static NetworkModel instance = new NetworkModel(); //public static NetworkModel GetInstance(){ return instance; } public NetworkLevel2Controller() { this.networkimplementation = NetworkImplementationFactory.CreateNewInstance(); networkimplementation.ReceivedPacket += new Level1ReceivedPacketHandler(ReceivedPacketHandler); //networkimplementation.NewConnection += new Level1NewConnectionHandler(networkimplementation_NewConnection); networkimplementation.Disconnection += new Level1DisconnectionHandler(networkimplementation_Disconnection); }
public void Go(int port) { net = NetworkImplementationFactory.CreateNewInstance(); net.ListenAsServer(port); net.ReceivedPacket += new Level1ReceivedPacketHandler(net_ReceivedPacket); while (true) { net.Tick(); Thread.Sleep(50); } }
public void Go(string ipaddress, int port) { INetworkImplementation net = NetworkImplementationFactory.CreateNewInstance(); net.ConnectAsClient(ipaddress, port); net.ReceivedPacket += new Level1ReceivedPacketHandler(net_ReceivedPacket); net.Send(Encoding.UTF8.GetBytes("Hi, this is a test")); while (true) { net.Tick(); Thread.Sleep(50); } }