public static void RegisterNewChannel(IncomingInterserverPacket packet) { RegisterNewChannelRequest request = new RegisterNewChannelRequest(packet); SharpFly_Utility_Library.Database.LoginDatabase.Tables.Cluster clusterTable = SharpFly_Utility_Library.Database.LoginDatabase.Queries.Cluster.Instance.GetCluster(request.ClusterId); uint clusterId = request.ClusterId; Cluster cluster = LoginServer.ClusterManager.GetClusterById(clusterId); if (clusterTable == null || request.AuthorizationPassword != clusterTable.Password) { cluster.SendRegisterNewChannelSuccesful(0, request.TempChannelId, false); Console.WriteLine("Couldn't register new channel to cluster {1}", cluster.ClusterData.Name); return; } if (cluster != null) { Channel channel = new Channel(); channel.Parent = cluster.ClusterData; channel.Id = ChannelId++; channel.Name = request.Name; channel.PlayerCount = 0; channel.MaxPlayerCount = request.MaxPlayerCount; cluster.ClusterData.Channels.Add(channel); cluster.SendRegisterNewChannelSuccesful(channel.Id, request.TempChannelId, true); Console.WriteLine("Registered channel {0} on cluster {1}", channel.Name, cluster.ClusterData.Name); return; } Console.WriteLine("Couldn't register new channel to cluster {1}", cluster.ClusterData.Name); }
public static void RegisterClusterRequest(IncomingInterserverPacket packet) { RegisterClusterRequest request = new RegisterClusterRequest(packet); SharpFly_Utility_Library.Database.LoginDatabase.Tables.Cluster clusterTable = SharpFly_Utility_Library.Database.LoginDatabase.Queries.Cluster.Instance.GetCluster(request.ClusterId); Cluster cluster = new Cluster(); cluster.ClientSocket = new PushSocket(String.Format(">tcp://{0}:{1}", request.Ip, request.SendPort)); cluster.ClusterData = new SharpFly_Packet_Library.Helper.Cluster(); cluster.ClusterData.Id = request.ClusterId; cluster.ClusterData.Name = clusterTable.Name; cluster.ClusterData.Ip = request.Ip; if (clusterTable == null) { cluster.SendRegisterClusterSuccesful(0, false); Console.WriteLine("Couldn't register cluster {0}: The cluster id {1} wasn't found in the database", cluster.ClusterData.Name, cluster.ClusterData.Id); return; } if (request.AuthorizationPassword != clusterTable.Password) { cluster.SendRegisterClusterSuccesful(0, false); Console.WriteLine("Couldn't register cluster {0}: Cluster authorization password was wrong", cluster.ClusterData.Name); return; } LoginServer.ClusterManager.AddCluster(cluster); cluster.SendRegisterClusterSuccesful(cluster.ClusterData.Id, true); Console.WriteLine("Cluster identified as {0}!", cluster.ClusterData.Name); }