Exemple #1
0
        private async void UpdateZorbo()
        {
            const string zorbo = "https://zorbo.ca/api/Channels/update";

            var record = new ServerDbRecord()
            {
                Name        = Server.Config.Name.StripColor(),
                Topic       = Server.Config.Topic.ToBase64(),
                Port        = Server.Config.Port,
                Users       = (ushort)(Server.Users.Count + 1),
                ExternalIp  = Server.ExternalIp.ToString(),
                InternalIp  = Server.InternalIp.ToString(),
                WebSockets  = Server.Config.UseWebSockets,
                SupportJson = server.Config.UseWebSockets,
                Language    = (byte)server.Config.Language,
                Version     = Strings.VersionChannels
            };

            if (!string.IsNullOrEmpty(Server.Config.Domain))
            {
                record.Domain  = Server.Config.Domain;
                record.TlsPort = Server.Config.TlsPort;
            }

            byte[] body = Encoding.UTF8.GetBytes(Json.Serialize(record));

            try {
                var request = WebRequest.CreateHttp(zorbo);

                request.Method        = "POST";
                request.ContentLength = body.Length;
                request.ContentType   = "application/json";

                using var stream = await request.GetRequestStreamAsync();

                await stream.WriteAsync(body, 0, body.Length);

                await stream.FlushAsync();

                using var response = await request.GetResponseAsync();

                using var reader = new StreamReader(response.GetResponseStream());

                string message = await reader.ReadToEndAsync();

                if (message != "OK")
                {
                    System.Diagnostics.Debug.WriteLine(message);
                }
            }
            catch {
                lastmars = DateTime.Now.Subtract(TimeSpan.FromMinutes(5));
                Logging.Warning("AresChannels", "Unable to send room update to {0}", zorbo);
            }
        }
Exemple #2
0
 public void CopyFrom(ServerDbRecord other)
 {
     Port        = other.Port;
     ExternalIp  = IPAddress.Parse(other.ExternalIp);
     InternalIp  = IPAddress.Parse(other.InternalIp);
     Name        = other.Name;
     Topic       = other.Topic;
     Domain      = other.Domain;
     TlsPort     = other.TlsPort;
     Users       = other.Users;
     Language    = (Language)other.Language;
     WebSockets  = other.WebSockets;
     SupportJson = other.SupportJson;
 }