GlowCommon.DiscoveryServer.InvokeBroadcast C# (CSharp) Method

InvokeBroadcast() public method

Can be called by the client to try to send a message to the server to broadcast.
public InvokeBroadcast ( ) : System.Threading.Tasks.Task
return System.Threading.Tasks.Task
        public async Task InvokeBroadcast()
        {
            try
            {
                // Send an message to try to get the server to respond.
                await SendMessage("Hello!");
            }
            catch(Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Unable to send server message. Message: " + e.Message);
            }
        }

Usage Example

Example #1
0
 /// <summary>
 /// Used to create a tick timer for the broadcast pinger
 /// </summary>
 private void CreateDiscoveryPingTimmer()
 {
     // Create the timer
     m_discoveryPingTimer = ThreadPoolTimer.CreatePeriodicTimer(async(ThreadPoolTimer source) =>
     {
         // When the timer fires try to send a message.
         await m_discoveryServer.InvokeBroadcast();
     },
                                                                // Fire every 2 seconds
                                                                new TimeSpan(0, 0, 2));
 }