本文整理汇总了C#中UnityEngine.Networking.NetworkConnection.Send方法的典型用法代码示例。如果您正苦于以下问题:C# NetworkConnection.Send方法的具体用法?C# NetworkConnection.Send怎么用?C# NetworkConnection.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Networking.NetworkConnection
的用法示例。
在下文中一共展示了NetworkConnection.Send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveClientAuthority
public bool RemoveClientAuthority(NetworkConnection conn)
{
if (!this.isServer)
{
if (LogFilter.logError)
{
Debug.LogError("RemoveClientAuthority can only be call on the server for spawned objects.");
}
return false;
}
if (this.connectionToClient != null)
{
if (LogFilter.logError)
{
Debug.LogError("RemoveClientAuthority cannot remove authority for a player object");
}
return false;
}
if (this.m_ClientAuthorityOwner == null)
{
if (LogFilter.logError)
{
Debug.LogError("RemoveClientAuthority for " + base.gameObject + " has no clientAuthority owner.");
}
return false;
}
if (this.m_ClientAuthorityOwner != conn)
{
if (LogFilter.logError)
{
Debug.LogError("RemoveClientAuthority for " + base.gameObject + " has different owner.");
}
return false;
}
this.m_ClientAuthorityOwner.RemoveOwnedObject(this);
this.m_ClientAuthorityOwner = null;
ClientAuthorityMessage msg = new ClientAuthorityMessage {
netId = this.netId,
authority = false
};
conn.Send(15, msg);
return true;
}
示例2: Ready
/// <summary>
/// <para>Signal that the client connection is ready to enter the game.</para>
/// </summary>
/// <param name="conn">The client connection which is ready.</param>
public static bool Ready(NetworkConnection conn)
{
if (ClientScene.s_IsReady)
{
if (LogFilter.logError)
Debug.LogError((object) "A connection has already been set as ready. There can only be one.");
return false;
}
if (LogFilter.logDebug)
Debug.Log((object) ("ClientScene::Ready() called with connection [" + (object) conn + "]"));
if (conn != null)
{
ReadyMessage readyMessage = new ReadyMessage();
conn.Send((short) 35, (MessageBase) readyMessage);
ClientScene.s_IsReady = true;
ClientScene.s_ReadyConnection = conn;
ClientScene.s_ReadyConnection.isReady = true;
return true;
}
if (LogFilter.logError)
Debug.LogError((object) "Ready() called with invalid connection object: conn=null");
return false;
}
示例3: OnServerAddPlayer
private void OnServerAddPlayer(NetworkConnection conn, short player_controller_id)
{
PlayerData pd = new PlayerData();
pd.ip = conn.address;
pd.ping = 0;
pd.ready = false;
pd.network_connection = conn;
pd.player_controller_id = player_controller_id;
_player_data.Add(conn.connectionId, pd);
conn.Send(MessageIDs.PlayerInfoRequest, new IntegerMessage(conn.connectionId));
}
示例4: FinishPlayerForConnection
private void FinishPlayerForConnection(NetworkConnection conn, NetworkIdentity uv, GameObject playerGameObject)
{
if (uv.netId.IsEmpty())
NetworkServer.Spawn(playerGameObject);
conn.Send((short) 4, (MessageBase) new OwnerMessage()
{
netId = uv.netId,
playerControllerId = uv.playerControllerId
});
}
示例5: SendCRC
private void SendCRC(NetworkConnection targetConnection)
{
if (NetworkCRC.singleton == null)
return;
CRCMessage crcMessage = new CRCMessage();
List<CRCMessageEntry> list = new List<CRCMessageEntry>();
using (Dictionary<string, int>.KeyCollection.Enumerator enumerator = NetworkCRC.singleton.scripts.Keys.GetEnumerator())
{
while (enumerator.MoveNext())
{
string current = enumerator.Current;
list.Add(new CRCMessageEntry()
{
name = current,
channel = (byte) NetworkCRC.singleton.scripts[current]
});
}
}
crcMessage.scripts = list.ToArray();
targetConnection.Send((short) 14, (MessageBase) crcMessage);
}
示例6: KickPlayer
public void KickPlayer(NetworkConnection conn)
{
conn.Send(MsgKicked, new KickMsg());
}
示例7: HideForConnection
internal static void HideForConnection(NetworkIdentity uv, NetworkConnection conn)
{
ObjectDestroyMessage msg = new ObjectDestroyMessage {
netId = uv.netId
};
conn.Send(13, msg);
}
示例8: HideForConnection
internal static void HideForConnection(NetworkIdentity uv, NetworkConnection conn)
{
conn.Send((short) 13, (MessageBase) new ObjectDestroyMessage()
{
netId = uv.netId
});
}
示例9: InternalSetClientNotReady
internal void InternalSetClientNotReady(NetworkConnection conn)
{
if (!conn.isReady)
return;
if (LogFilter.logDebug)
Debug.Log((object) ("PlayerNotReady " + (object) conn));
conn.isReady = false;
conn.RemoveObservers();
NotReadyMessage notReadyMessage = new NotReadyMessage();
conn.Send((short) 36, (MessageBase) notReadyMessage);
}
示例10: RemoveClientAuthority
/// <summary>
/// <para>Removes ownership for an object for a client by its conneciton.</para>
/// </summary>
/// <param name="conn">The connection of the client to remove authority for.</param>
/// <returns>
/// <para>True if authority is removed.</para>
/// </returns>
public bool RemoveClientAuthority(NetworkConnection conn)
{
if (!this.isServer)
{
if (LogFilter.logError)
Debug.LogError((object) "RemoveClientAuthority can only be call on the server for spawned objects.");
return false;
}
if (this.connectionToClient != null)
{
if (LogFilter.logError)
Debug.LogError((object) "RemoveClientAuthority cannot remove authority for a player object");
return false;
}
if (this.m_ClientAuthorityOwner == null)
{
if (LogFilter.logError)
Debug.LogError((object) ("RemoveClientAuthority for " + (object) this.gameObject + " has no clientAuthority owner."));
return false;
}
if (this.m_ClientAuthorityOwner != conn)
{
if (LogFilter.logError)
Debug.LogError((object) ("RemoveClientAuthority for " + (object) this.gameObject + " has different owner."));
return false;
}
this.m_ClientAuthorityOwner.RemoveOwnedObject(this);
this.m_ClientAuthorityOwner = (NetworkConnection) null;
this.ForceAuthority(true);
conn.Send((short) 15, (MessageBase) new ClientAuthorityMessage()
{
netId = this.netId,
authority = false
});
if (NetworkIdentity.clientAuthorityCallback != null)
NetworkIdentity.clientAuthorityCallback(conn, this, false);
return true;
}
示例11: Ready
/// <summary>
/// <para>Signal that the client connection is ready to enter the game.</para>
/// </summary>
/// <param name="conn">The client connection which is ready.</param>
public static bool Ready(NetworkConnection conn)
{
if (s_IsReady)
{
if (LogFilter.logError)
{
Debug.LogError("A connection has already been set as ready. There can only be one.");
}
return false;
}
if (LogFilter.logDebug)
{
Debug.Log("ClientScene::Ready() called with connection [" + conn + "]");
}
if (conn != null)
{
ReadyMessage msg = new ReadyMessage();
conn.Send(0x23, msg);
s_IsReady = true;
s_ReadyConnection = conn;
s_ReadyConnection.isReady = true;
return true;
}
if (LogFilter.logError)
{
Debug.LogError("Ready() called with invalid connection object: conn=null");
}
return false;
}
示例12: AssignClientAuthority
/// <summary>
/// <para>This assigns control of an object to a client via the client's NetworkConnection.</para>
/// </summary>
/// <param name="conn">The connection of the client to assign authority to.</param>
/// <returns>
/// <para>True if authority was assigned.</para>
/// </returns>
public bool AssignClientAuthority(NetworkConnection conn)
{
if (!this.isServer)
{
if (LogFilter.logError)
Debug.LogError((object) "AssignClientAuthority can only be call on the server for spawned objects.");
return false;
}
if (!this.localPlayerAuthority)
{
if (LogFilter.logError)
Debug.LogError((object) "AssignClientAuthority can only be used for NetworkIdentity component with LocalPlayerAuthority set.");
return false;
}
if (this.m_ClientAuthorityOwner != null && conn != this.m_ClientAuthorityOwner)
{
if (LogFilter.logError)
Debug.LogError((object) ("AssignClientAuthority for " + (object) this.gameObject + " already has an owner. Use RemoveClientAuthority() first."));
return false;
}
if (conn == null)
{
if (LogFilter.logError)
Debug.LogError((object) ("AssignClientAuthority for " + (object) this.gameObject + " owner cannot be null. Use RemoveClientAuthority() instead."));
return false;
}
this.m_ClientAuthorityOwner = conn;
this.m_ClientAuthorityOwner.AddOwnedObject(this);
this.ForceAuthority(false);
conn.Send((short) 15, (MessageBase) new ClientAuthorityMessage()
{
netId = this.netId,
authority = true
});
if (NetworkIdentity.clientAuthorityCallback != null)
NetworkIdentity.clientAuthorityCallback(conn, this, true);
return true;
}
示例13: OnServerAddPlayer
public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
{
if (SceneManager.GetSceneAt(0).name != this.m_LobbyScene)
return;
int num = 0;
using (List<PlayerController>.Enumerator enumerator = conn.playerControllers.GetEnumerator())
{
while (enumerator.MoveNext())
{
if (enumerator.Current.IsValid)
++num;
}
}
if (num >= this.maxPlayersPerConnection)
{
if (LogFilter.logWarn)
Debug.LogWarning((object) "NetworkLobbyManager no more players for this connection.");
EmptyMessage emptyMessage = new EmptyMessage();
conn.Send((short) 45, (MessageBase) emptyMessage);
}
else
{
byte slot = this.FindSlot();
if ((int) slot == (int) byte.MaxValue)
{
if (LogFilter.logWarn)
Debug.LogWarning((object) "NetworkLobbyManager no space for more players");
EmptyMessage emptyMessage = new EmptyMessage();
conn.Send((short) 45, (MessageBase) emptyMessage);
}
else
{
GameObject player = this.OnLobbyServerCreateLobbyPlayer(conn, playerControllerId);
if ((Object) player == (Object) null)
player = (GameObject) Object.Instantiate((Object) this.lobbyPlayerPrefab.gameObject, Vector3.zero, Quaternion.identity);
NetworkLobbyPlayer component = player.GetComponent<NetworkLobbyPlayer>();
component.slot = slot;
this.lobbySlots[(int) slot] = component;
NetworkServer.AddPlayerForConnection(conn, player, playerControllerId);
}
}
}
示例14: InternalSetClientNotReady
internal void InternalSetClientNotReady(NetworkConnection conn)
{
if (conn.isReady)
{
if (LogFilter.logDebug)
{
Debug.Log("PlayerNotReady " + conn);
}
conn.isReady = false;
conn.RemoveObservers();
NotReadyMessage msg = new NotReadyMessage();
conn.Send(0x24, msg);
}
}
示例15: AssignClientAuthority
public bool AssignClientAuthority(NetworkConnection conn)
{
if (!this.isServer)
{
if (LogFilter.logError)
{
Debug.LogError("AssignClientAuthority can only be call on the server for spawned objects.");
}
return false;
}
if (!this.localPlayerAuthority)
{
if (LogFilter.logError)
{
Debug.LogError("AssignClientAuthority can only be used for NetworkIdentity component with LocalPlayerAuthority set.");
}
return false;
}
if ((this.m_ClientAuthorityOwner != null) && (conn != this.m_ClientAuthorityOwner))
{
if (LogFilter.logError)
{
Debug.LogError("AssignClientAuthority for " + base.gameObject + " already has an owner. Use RemoveClientAuthority() first.");
}
return false;
}
if (conn == null)
{
if (LogFilter.logError)
{
Debug.LogError("AssignClientAuthority for " + base.gameObject + " owner cannot be null. Use RemoveClientAuthority() instead.");
}
return false;
}
this.m_ClientAuthorityOwner = conn;
this.m_ClientAuthorityOwner.AddOwnedObject(this);
ClientAuthorityMessage msg = new ClientAuthorityMessage {
netId = this.netId,
authority = true
};
conn.Send(15, msg);
return true;
}