public RemoteProvider(string IP, int Port) { var socket = new NLCSocket(true, true); client = new NotLiteCode.Client(socket, true); client.Connect(IP, Port); }
public RemoteProvider(IDBProvider db) { var socket = new NLCSocket(true, Helpers.GenerateSelfSignedCert("nalp", "localhost")); DB = db; server = new Server <SharedClass>(socket); server.OnServerClientConnected += (x, y) => Helpers.Log($"NLC: Client {y.Client} connected!", ConsoleColor.Green); server.OnServerClientDisconnected += (x, y) => Helpers.Log($"NLC: Client {y.Client} disconnected!", ConsoleColor.Yellow); server.OnServerExceptionOccurred += (x, y) => Helpers.Log($"NLC: Exception Occured! {y.Exception}", ConsoleColor.Red); }
public Client(NLCSocket ClientSocket, bool UseCallbacks) { this.ClientSocket = ClientSocket; this.UseCallbacks = UseCallbacks; if (UseCallbacks && ClientSocket.BaseSocket.Connected) { if (!ClientSocket.ContinueSubscribing) { ClientSocket.ContinueSubscribing = true; } ClientSocket.OnNetworkMessageReceived += OnCallbackMessageReceived; } }
private static void Main(string[] args) { Console.Title = "NLC Server"; var ServerSocket = new NLCSocket(new GroBufSerializationProvider(), UseSSL: true, ServerCertificate: GenerateSelfSignedCert("NLC", "localhost")); var Server = new Server <SharedClass>(ServerSocket); Server.OnServerClientConnected += (x, y) => Log($"Client {y.Client} connected!", ConsoleColor.Green); Server.OnServerClientDisconnected += (x, y) => Log($"Client {y.Client} disconnected!", ConsoleColor.Yellow); Server.OnServerExceptionOccurred += (x, y) => Log($"Exception Occured! {y.Exception}", ConsoleColor.Red); // This line intentionally left commented due to excessive lock contestion during performance testing (1000's of calls a second) which starves other performance critical threads thus skewing performance results //Server.OnServerMethodInvoked += (x, y) => Log($"Client {y.Client} {(y.WasErroneous ? "failed to invoke" : "invoked")} {y.Identifier} for {y.Duration.TotalMilliseconds}ms.", y.WasErroneous ? ConsoleColor.Yellow : ConsoleColor.Cyan); Server.Start(); Log("Server Started!", ConsoleColor.Green); Process.GetCurrentProcess().WaitForExit(); }
private static async Task Main() { Console.Title = "NLC Client"; // Create a socket with encryption enabled var ClientSocket = new NLCSocket(new GroBufSerializationProvider(), UseSSL: true, AllowInsecureCerts: true); Client = new Client(ClientSocket); Client.Connect("localhost", 1337); // Invoke our first remote method await Test(); // Invoke a method that returns a string Console.WriteLine(await CombineTwoStringsAndReturn("I'm a ", "real boy!")); int l = 0; var t = Stopwatch.StartNew(); // Execute a method as many times as we can in 1 second while (t.ElapsedMilliseconds < 1000) { await SpeedTest(); l++; } t.Stop(); Console.WriteLine("{0} calls in 1 second!", l); Client.Stop(); Console.ReadLine(); }
public void ManuallyConnectSocket(NLCSocket Socket) { OnNetworkClientConnected(null, new OnNetworkClientConnectedEventArgs(Socket)); }
public Server(NLCSocket ServerSocket) { this.ServerSocket = ServerSocket; RegisterFunctions(); }
public RemoteClient(NLCSocket Socket) { this.Socket = Socket; this.SharedClass = new T(); }
public void DetatchFromSocket(NLCSocket Socket) { Socket.OnNetworkClientDisconnected -= NetworkClientDisconnected; Socket.OnNetworkExceptionOccurred -= NetworkExceptionOccurred; Socket.OnNetworkMessageReceived -= OnNetworkMessageReceived; }
public Client(NLCSocket ClientSocket) : this(ClientSocket, false) { }