示例#1
0
    public bool ConnectToServer(string ipaddr, string port)
    {
        this.comSvcIPaddr = ipaddr;
        this.comSvcPort   = DefaultPort;
        if ((port != null) && (port != ""))
        {
            this.comSvcPort = port;
        }

        if (comSvc == null)
        {
            comSvc = new ComServiceServer();
        }
        if (comSvc.IsRunning() == false)
        {
            comSvc.StartService(masterClient, comSvcPort);
        }

        if (((ipaddr == "127.0.0.1") || (ipaddr == "localhost")) &&
            (masterClient == false))
        {
            Debug.Log("Cannot connect to local com service unless you are the host (master) client");
            return(false);
        }

        if (comCli == null)
        {
            comCli = new ComClient(ipaddr, comSvcPort, GetPlayerName());
        }
        return(comCli.PingService());
    }
示例#2
0
 public PubSubService()
 {
     clientChannels = new List <ChannelType>();
     channelLists   = new Dictionary <ChannelType, List <Subscriber> >();
     css            = new ComServiceServer();
     css.StartService();
     CreateChannel(ChannelType.Clientstate);
 }