/// <summary> /// Event invoked from HiveCommunicationClient Client /// </summary> /// <param name="pMessage"></param> private void ClientOnNewMessage(ScsTextMessage pMessage) { string[] lvSplit = pMessage.Text.Split(':'); switch (lvSplit[0].ToLower()) { case "username": if (lvSplit[1].ToLower() == "ok") { this.Client.UsernameConfirmed = true; if (this.OnUsernameConfirmed != null) { this.OnUsernameConfirmed.Invoke(); } } else if (lvSplit[1].ToLower() == "error") { InputHiveClientForm.ShowMessageBox("Username is not valid.", "Username is not valid", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case "chat": string lvText = pMessage.Text.Remove(0, 5); InputHiveClientForm.ChatQueue.Enqueue(lvText); break; case "full": this.Client.Disconnect(); InputHiveClientForm.ShowMessageBox("The server is full.", "Server is full", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; case "notallow": this.Client.Disconnect(); InputHiveClientForm.ShowMessageBox("The server is not allowing any new clients.", "Not allowed to join", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; case "kick": this.Client.Disconnect(); InputHiveClientForm.ShowMessageBox("You have been kicked from the server.", "Kicked", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; case "ban": this.Client.Disconnect(); InputHiveClientForm.ShowMessageBox("You have been banned from the server.", "Banned", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; case "keylist": this.AddNewKeyList(pMessage.Text.Remove(0, 8)); InputHiveClientForm.LoggingQueue.Enqueue(String.Format( "{0} Received keylist update.", DateTime.Now)); break; case "sendnotallowed": InputHiveClientForm.LoggingQueue.Enqueue(String.Format( "{0} failed to send key. Not allowed to send keys.", DateTime.Now)); break; case "sendnotallowedkey": InputHiveClientForm.LoggingQueue.Enqueue(String.Format( "{0} failed to send key. Not allowed to send this key.", DateTime.Now)); break; case "sendnotallowedcooldown": InputHiveClientForm.LoggingQueue.Enqueue(String.Format( "{0} failed to send key. Not allowed to send yet.", DateTime.Now)); break; case "nosend": InputHiveClientForm.LoggingQueue.Enqueue(String.Format( "{0} failed to send key. Server not allowing keys to be sent.", DateTime.Now)); break; case "screenshot": Image image = StaticHelper.Base64ToImage(lvSplit[1]); this._form.UpdateScreenShot(image); break; default: InputHiveClientForm.ShowMessageBox("Unknown message:\n" + pMessage.Text, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } }