Skip to content

Commit

Permalink
Cleanup client protocol settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
veblush committed Jul 13, 2016
1 parent 6404798 commit 1130427
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private IEnumerator ProcessLogin(string server, ChannelType type, string id, str
var communicator = UnityCommunicatorFactory.Create();
{
var channelFactory = communicator.ChannelFactory;
channelFactory.Type = ChannelType.Tcp;
channelFactory.Type = type;
channelFactory.ConnectEndPoint = serverEndPoint;
channelFactory.CreateChannelLogger = () => LogManager.GetLogger("Channel");
channelFactory.PacketSerializer = PacketSerializer.CreatePacketSerializer<DomainProtobufSerializer>();
Expand Down
6 changes: 3 additions & 3 deletions src/TalkServer/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
name = ChatCluster
runner {
default = [
{ port = 3001, roles = [ "RoomTable", "UserTable", "BotTable", [ "Room", { port = 9021 } ], [ "User", { port = 9011 } ], [ "UserLogin", { port = 9001 } ], "Bot" ] }
{ port = 3001, roles = [ "RoomTable", "UserTable", "BotTable", "Room", "User", [ "UserLogin", { port = 9001 } ], "Bot" ] }
]
cluster = [
{ port = 3001, roles = [ "RoomTable" ] }
{ port = 3002, roles = [ "UserTable" ] }
{ port = 3003, roles = [ "BotTable" ] }
{ port = 3011, roles = [ [ "Room", { port = 9021 } ] ] }
{ port = 3012, roles = [ [ "Room", { port = 9022 } ] ] }
{ port = 3011, roles = [ [ "Room", { port = 9021 } ] ] }
{ port = 3012, roles = [ [ "Room", { port = 9022 } ] ] }
{ port = 3021, roles = [ [ "User", { port = 9011 } ] ] }
{ port = 3022, roles = [ [ "User", { port = 9012 } ] ] }
{ port = 3031, roles = [ [ "UserLogin", { port = 9001 } ] ] }
Expand Down
15 changes: 9 additions & 6 deletions src/TalkServer/ClusterRoleWorkers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class UserWorker : ClusterRoleWorker
public UserWorker(ClusterNodeContext context, Config config)
{
_context = context;
_channelType = (ChannelType)Enum.Parse(typeof(ChannelType), config.GetString("type", "Tcp"));
_channelType = (ChannelType)Enum.Parse(typeof(ChannelType), config.GetString("type", "Tcp"), true);
_listenEndPoint = new IPEndPoint(IPAddress.Any, config.GetInt("port", 0));

var connectAddress = config.GetString("connect-address");
Expand Down Expand Up @@ -141,7 +141,7 @@ public class UserLoginWorker : ClusterRoleWorker
public UserLoginWorker(ClusterNodeContext context, Config config)
{
_context = context;
_channelType = (ChannelType)Enum.Parse(typeof(ChannelType), config.GetString("type", "Tcp"));
_channelType = (ChannelType)Enum.Parse(typeof(ChannelType), config.GetString("type", "Tcp"), true);
_listenEndPoint = new IPEndPoint(IPAddress.Any, config.GetInt("port", 0));
}

Expand Down Expand Up @@ -221,7 +221,7 @@ public class RoomWorker : ClusterRoleWorker
public RoomWorker(ClusterNodeContext context, Config config)
{
_context = context;
_channelType = (ChannelType)Enum.Parse(typeof(ChannelType), config.GetString("type", "Tcp"));
_channelType = (ChannelType)Enum.Parse(typeof(ChannelType), config.GetString("type", "Tcp"), true);
_listenEndPoint = new IPEndPoint(IPAddress.Any, config.GetInt("port", 0));
_connectEndPoint = new IPEndPoint(IPAddress.Parse(config.GetString("address", "127.0.0.1")), config.GetInt("port", 0));
}
Expand Down Expand Up @@ -264,9 +264,12 @@ public override async Task Stop()
{
// stop gateway

await _gateway.CastToIActorRef().GracefulStop(
TimeSpan.FromSeconds(10),
InterfacedMessageBuilder.Request<IGateway>(x => x.Stop()));
if (_gateway != null)
{
await _gateway.CastToIActorRef().GracefulStop(
TimeSpan.FromSeconds(10),
InterfacedMessageBuilder.Request<IGateway>(x => x.Stop()));
}

// stop room container

Expand Down

0 comments on commit 1130427

Please sign in to comment.