protected virtual void OnSMLPMessageReceived(SMLPMessage msg) { if (SMLPMessageReceived != null) { SMLPMessageReceived(this, msg); } }
/// <summary> /// Verschickt eine SMLP-Nachricht an den angegebenen Client /// </summary> /// <param name="msg">Die Nachricht</param> /// <param name="client">Der Client</param> public void SendMessage(SMLPMessage msg, ClientInfo client) { if (client.IPAddress != null) { Log("Send: " + msg.Data.Length + " bytes"); msg.WriteMessage(this.udp_client, client.GetUDPEndPoint()); } }
/// <summary> /// Wenn Audio aufgenommen wurde, wird es an die anderen /// Teilnehmer geschickt /// </summary> /// <param name="audio">Das aufgenommene Audio</param> public void ShareAudio(byte[] audio) { if (IsConnected) { SMLPMessage smlp = Connection.CreateMessage(audio, SMLPMessage.AUDIO); Connection.MulticastMessage(smlp); } }
/// <summary> /// Erstellt eine SMLP-Nachricht und personalisiert diese für den /// lokalen Computer /// </summary> /// <param name="data">Die Daten als Byte-Array, werden nicht weiter verarbeitet</param> /// <param name="localReceiver">Der LOCAL_RECEIVER (Siehe ScrumNetwork.Protocol.SMLPMessage)</param> /// <returns>Die Nachricht</returns> public SMLPMessage CreateMessage(byte[] data, short localReceiver) { SMLPMessage msg = new SMLPMessage(); msg.SenderID = LocalClient.ClientID; msg.Data = data; msg.LocalReceiver = localReceiver; return(msg); }
/// <summary> /// Versendet eine SMLP-Nachricht an alle verbundenen Clients /// </summary> /// <param name="msg">Die Nachricht</param> public void MulticastMessage(SMLPMessage msg) { foreach (ClientInfo ci in ConnectedClients.Values) { if (ci.ClientID != msg.SenderID && ci.ClientID != this.LocalClient.ClientID && ci.UdpPort > 0) { SendMessage(msg, ci); } } }
/// <summary> /// Wenn beim Bearbeiten eines Items der Inhalt eines Textfelds bearbeitet wurde, /// wird an dieser Stelle der Status des Textfelds den anderen Teilnehmern mitgeteilt. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Database_NetworkDataAvailable(object sender, ScrumTouchkit.Events.TextBoxStateEventArgs e) { if (!IsConnected) { return; } SMLPMessage msg = Connection.CreateMessage(e.State, e.Data.ItemID); Connection.MulticastMessage(msg); }
/// <summary> /// Wartet auf neue SMLP Nachrichten am UDP-Port /// </summary> protected void ListenForSMLP() { SMLPMessage message; while (!IsClosing) { try { message = SMLPMessage.ReadNextMessage(udp_client); } catch (Exception e) { Console.WriteLine(e.Message); break; } if (message != null) { OnSMLPMessageReceived(message); } } }