/// <summary> /// This method is invoked when the client has been approved of connecting to the server. The client should /// be constructed in this method, and cipher algorithms should be initialized. If any packets need to be /// sent in the connection state, they should be sent here. /// </summary> /// <param name="pState">Represents the status of an asynchronous operation.</param> public void Connect(AsynchronousState pState) { var pServer = new PatchServer(this, pState.Socket); pState.Client = pServer; Program.FrmMain.Edit(Program.FrmMain.lblCenterStatus, LabelAsyncOperation.Text, LanguageManager.GetString("StrCheckingPrivacyTerms")); MsgClientInfo msg = new MsgClientInfo(); msg.MacAddress = Program.FrmMain.GetMacAddress(); msg.Append(SystemProperties.GetObjects(MsgClientInfo.OPERATING_SYSTEM, MsgClientInfo.OperatingSystem).Values.ToArray()); msg.Append(SystemProperties.GetObjects(MsgClientInfo.BASE_BOARD, MsgClientInfo.BaseBoard).Values.ToArray()); msg.Append(SystemProperties.GetObjects(MsgClientInfo.PROCESSOR, MsgClientInfo.Processor).Values.ToArray()); msg.Append(SystemProperties.GetObjects(MsgClientInfo.PHYSICAL_MEMORY, MsgClientInfo.PhysicalMemory).Values.ToArray()); msg.Append(SystemProperties.GetObjects(MsgClientInfo.VIDEO_CONTROLLER, MsgClientInfo.VideoController).Values.ToArray()); pServer.Send(msg); }
public void ProcessClientInfo(User user, byte[] buffer) { /** * Todo store user data securely * Todo develop something to encrypt data */ MsgClientInfo msg = new MsgClientInfo(buffer); Program.WriteLog($"IPAddress [{user.IpAddress}] has connected [MacAddress:{msg.MacAddress}]"); /** * Todo Send user info and Mac Address to the login server to allow connections. */ user.MacAddress = msg.MacAddress; if (Kernel.AllowedUsers.ContainsKey(user.MacAddress) || !Kernel.AllowedUsers.TryAdd(user.MacAddress, user)) { user.Send(new MsgRequestInfo { CurrentVersion = 0, Mode = AutoUpdateRequestType.CheckForGameUpdates }); return; } /** * Sends the latest update! Since it's web host we wont have problems with this. The client * will just display the page! :D */ MsgClientInfo back = new MsgClientInfo(); back.MacAddress = msg.MacAddress; back.Append(Kernel.PrivacyTermsUpdate.ToString("yyyy-MM-dd HH:mm:ss")); user.Send(back); }