feat: NetworkClient
This commit is contained in:
		
							
								
								
									
										21
									
								
								Game/Network/NetworkClient.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								Game/Network/NetworkClient.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					using LiteNetLib;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Game.Network;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class NetworkClient
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public readonly EventBasedNetListener Listener = null!;
 | 
				
			||||||
 | 
					    public readonly NetManager Client = null!;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public NetworkClient()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Listener = new EventBasedNetListener();
 | 
				
			||||||
 | 
					        Client = new NetManager(Listener);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void Connect(string address, int port, string? password = null)
 | 
				
			||||||
 | 
					        => Client.Connect(address, port, password ?? string.Empty);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void PollEvents() => Client.PollEvents();
 | 
				
			||||||
 | 
					    public void Stop() => Client.Stop();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user