void KeepConnected()
    {
        if (String.IsNullOrEmpty(host) || port == 0)
        {
            return;
        }

        if (cachedHost != host || target.port != port)
        {
            cachedHost = host;
            target = new uLink.NetworkPeer(host, port);
        }

        switch (p2p.GetStatus(target))
        {
            case uLink.NetworkStatus.Disconnected:
                lastTimeConnecting = Time.time;
                p2p.Connect(target, incomingPassword);
                break;

            case uLink.NetworkStatus.Connecting:
                if (Single.IsNaN(lastTimeConnecting)) lastTimeConnecting = Time.time;
                else if (Time.time >= lastTimeConnecting + connectingTimeout) p2p.CloseConnection(target, true);
                break;

            default:
                lastTimeConnecting = Single.NaN;
                break;
        }
    }
Ejemplo n.º 2
0
 static void P2PRPC(string func, uLink.NetworkPeer peer, params object[] args)
 {
     try
     {
         p2p.RPC(func, peer, args);
     }
     catch (Exception e)
     {
         if (LogFilter.logFatal)
         {
             Debug.LogErrorFormat("{0}\r\n{1}\r\n{2}", func, e.Message, e.StackTrace);
         }
     }
 }
Ejemplo n.º 3
0
    public void uLink_OnPeerDisconnected(uLink.NetworkPeer peer)
    {
        ConnectedServer server = connectedServers.Find(it => it.peer == peer);

        if (server != null)
        {
            connectedServers.Remove(server);

            if (null != OnServerDisconnectedEvent)
            {
                OnServerDisconnectedEvent(server.serverName, (int)server.sceneMode);
            }

            if (LogFilter.logDebug)
            {
                Debug.LogFormat("{0} closed", server.serverName);
            }
        }
    }
    void KeepConnected()
    {
        if (String.IsNullOrEmpty(host) || port == 0)
        {
            return;
        }

        if (cachedHost != host || target.port != port)
        {
            cachedHost = host;
            target     = new uLink.NetworkPeer(host, port);
        }

        switch (p2p.GetStatus(target))
        {
        case uLink.NetworkStatus.Disconnected:
            lastTimeConnecting = Time.time;
            p2p.Connect(target, incomingPassword);
            break;

        case uLink.NetworkStatus.Connecting:
            if (Single.IsNaN(lastTimeConnecting))
            {
                lastTimeConnecting = Time.time;
            }
            else if (Time.time >= lastTimeConnecting + connectingTimeout)
            {
                p2p.CloseConnection(target, true);
            }
            break;

        default:
            lastTimeConnecting = Single.NaN;
            break;
        }
    }
 /// <summary>
 /// Moves a network object and it's owner to another server.
 /// Adjusts the players position and rotation on the receiving peer according to the given relative parameters.
 /// </summary>
 /// <remarks>
 /// Can only be invoked server-side.
 /// The player's client will automatically be reconnected to the new server.
 /// </remarks>
 public void Handover(Object obj, NetworkPeer target, Vector3 relativePos, Quaternion relativeRot)
 {
     base.Handover(Require(obj), target, relativePos, relativeRot);
 }
 public void Handover(Object obj, NetworkPeer target, bool keepPlayerID)
 {
     base.Handover(Require(obj), target);
 }
 /// <summary>
 /// Moves a network aware object to a remote node.
 /// Adjusts the objects position and rotation on the receiving node according to the given relative parameters.
 /// </summary>
 /// <param name="obj">The network aware object which you want to move to another remote node</param>
 /// <param name="target">The <see cref="uLink.NetworkPeer"/> which <c>obj</c> should be moved to</param>
 /// <param name="relativePos">The position which the <c>obj</c>'s position should be set to in other node</param>
 /// <param name="relativeRot">The rotation which the <c>obj</c>'s rotation should be set to in other node</param>
 /// <param name="flags">The <see cref="uLink.NetworkP2PHandoverFlags"/> which sets the setting of HandOver</param>
 /// <param name="handoverData">The data which can be used in <see cref="NetworkP2P.uLink_OnHandoverNetworkView"/> in other node</param>
 /// <remarks>
 /// Can only be invoked server-side.
 /// owner redirection and instantiations can be customized
 /// using the <c>flags</c> argument.
 /// </remarks>
 public void Handover(Object obj, NetworkPeer target, Vector3 relativePos, Quaternion relativeRot, NetworkP2PHandoverFlags flags, params object[] handoverData)
 {
     base.Handover(Require(obj), target, relativePos, relativeRot, flags, handoverData);
 }
 /// <summary>
 /// Moves a network object and it's owner to another server.
 /// </summary>
 /// <param name="obj">The network aware object which you want to move to another remote node</param>
 /// <param name="target">The <see cref="uLink.NetworkPeer"/> which <c>obj</c> should be moved to</param>
 /// <remarks>
 /// Can only be invoked server-side.
 /// The player's client will automatically be reconnected to the new server and
 /// the object will be instantiated with a new viewID on the receiving end.
 /// </remarks>
 public void Handover(Object obj, NetworkPeer target)
 {
     base.Handover(Require(obj), target);
 }
 public void Replicate(Object obj, NetworkPeer target, Vector3 relativePos, Quaternion relativeRot)
 {
     base.Replicate(Require(obj), target, relativePos, relativeRot);
 }
 /// <summary>
 /// Moves a network aware object to a remote node.
 /// </summary>
 /// <param name="obj">The network aware object which you want to move to another remote node</param>
 /// <param name="target">The <see cref="uLink.NetworkPeer"/> which <c>obj</c> should be moved to</param>
 /// <param name="flags">The <see cref="uLink.NetworkP2PHandoverFlags"/> which sets the setting of HandOver</param>
 /// <param name="handoverData">The data which can be used in <see cref="NetworkP2P.uLink_OnHandoverNetworkView"/> in other node</param>
 /// <remarks>
 /// Can only be invoked server-side.
 /// owner redirection and instantiations can be customized
 /// using the <c>flags</c> argument.
 /// </remarks>
 public void Handover(Object obj, NetworkPeer target, NetworkP2PHandoverFlags flags, params object[] handoverData)
 {
     base.Handover(Require(obj), target, flags, handoverData);
 }
Ejemplo n.º 11
0
 internal NetworkP2PMessageInfo(NetworkP2PMessage msg, NetworkP2PBase p2p)
 {
     sender     = new NetworkPeer(msg.connection.RemoteEndpoint);
     flags      = msg.flags;
     networkP2P = p2p as P2P;
 }
 public void Replicate(Object obj, NetworkPeer target)
 {
     base.Replicate(Require(obj), target);
 }
 public void Handover(Object obj, NetworkPeer target, bool keepPlayerID, Vector3 offsetPos, Quaternion offsetRot)
 {
     base.Handover(Require(obj), target, offsetPos, offsetRot);
 }
 public void WriteNetworkPeer(NetworkPeer value)
 {
     value._Write(_buffer);
 }
Ejemplo n.º 15
0
 void uLink_OnPeerDisconnected(uLink.NetworkPeer peer)
 {
     SendSwitch(false);
 }
Ejemplo n.º 16
0
 void uLink_OnPeerConnected(uLink.NetworkPeer peer)
 {
     SendSwitch(true);
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Initializes a NetworkP2PMessageInfo.
 /// You should not need to use this in most situations.
 /// Don't use it unless you really know what you are doing.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="flags"></param>
 /// <param name="networkP2P"></param>
 public NetworkP2PMessageInfo(NetworkPeer sender, NetworkFlags flags, P2P networkP2P)
 {
     this.sender     = sender;
     this.flags      = flags;
     this.networkP2P = networkP2P;
 }
 /// <summary>
 /// Creates a P2P connection to another node using its <see cref="uLink.NetworkPeer"/>.
 /// </summary>
 /// <param name="target">The <see cref="uLink.NetworkPeer"/> of other node</param>
 /// <remarks>
 /// If the other node requires password to allow connections use <see cref="Connect(uLink.NetworkPeer, System.String)"/>
 /// </remarks>
 public void Connect(NetworkPeer target)
 {
     Connect(target, String.Empty);
 }
Ejemplo n.º 19
0
 public ConnectedServer(string serverName, int sceneMode, uLink.NetworkPeer peer)
 {
     this.serverName = serverName;
     this.sceneMode  = (Pathea.PeGameMgr.ESceneMode)sceneMode;
     this.peer       = peer;
 }