Example #1
0
        public OutgoingServerToServerPeer(IRpcProtocol protocol, IPhotonPeer peer, IOutgoingServerPeer outgoingServerPeerHandler)
            : base(protocol, peer)
        {
            if (outgoingServerPeerHandler == null)
            {
                throw new NullReferenceException("outgoingServerPeerHandler");
            }

            this.outgoingServerPeerHandler = outgoingServerPeerHandler;
            this.outgoingServerPeerHandler.OnConnect(this);
        }
        /// <summary>
        /// Connects to a server with a custom <see cref="IOutgoingServerPeer"/>.
        /// </summary>
        /// <param name="ipEndPoint"></param>
        /// <param name="applicationName"></param>
        /// <param name="outgoingServerPeerHandler"></param>
        /// <returns></returns>
        public bool ConnectToExternalServer(IPEndPoint ipEndPoint, string applicationName, IOutgoingServerPeer outgoingServerPeerHandler)
        {
            var callbackId = Utils.NewGuidInt64(GuidCreationCulture.Utc);

            if (ConnectToServerTcp(ipEndPoint, applicationName, callbackId))
            {
                lock (pendingExternalServerConnections)
                    this.pendingExternalServerConnections.Add(callbackId, outgoingServerPeerHandler);
                return(true);
            }
            return(false);
        }