本文整理汇总了C#中NetworkConnection.Send方法的典型用法代码示例。如果您正苦于以下问题:C# NetworkConnection.Send方法的具体用法?C# NetworkConnection.Send怎么用?C# NetworkConnection.Send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkConnection
的用法示例。
在下文中一共展示了NetworkConnection.Send方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnGetTitleData
private void OnGetTitleData(NetworkConnection connection, GetTitleDataResult result)
{
//Do something cool with title data and Return back to the client.
var output = string.Format("Recieved {0} Title Data Keys", result.Data.Keys.Count);
Logger.Dispatch(LoggerTypes.Info, output);
connection.Send(1002, new StringMessage()
{
value = string.Format(output)
});
}
示例2: OnServerAddPlayer
public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
{
// check MaxPlayersPerConnection
int numPlayersForConnection = 0;
foreach (var player in conn.playerControllers)
{
if (player.IsValid)
numPlayersForConnection += 1;
}
if (numPlayersForConnection >= maxPlayersPerConnection)
{
if (LogFilter.logWarn) { Debug.LogWarning("NetworkLobbyManager no more players for this connection."); }
var errorMsg = new EmptyMessage();
conn.Send(MsgType.LobbyAddPlayerFailed, errorMsg);
return;
}
byte slot = FindSlot();
if (slot == Byte.MaxValue)
{
if (LogFilter.logWarn) { Debug.LogWarning("NetworkLobbyManager no space for more players"); }
var errorMsg = new EmptyMessage();
conn.Send(MsgType.LobbyAddPlayerFailed, errorMsg);
return;
}
var newLobbyGameObject = OnLobbyServerCreateLobbyPlayer(conn, playerControllerId);
if (newLobbyGameObject == null)
{
newLobbyGameObject = (GameObject)Instantiate(playerPrefab.gameObject, Vector3.zero, Quaternion.identity);
}
var newLobbyPlayer = newLobbyGameObject.GetComponent<CaptainsMessPlayer>();
newLobbyPlayer.slot = slot;
lobbySlots[slot] = newLobbyPlayer;
NetworkServer.AddPlayerForConnection(conn, newLobbyGameObject, playerControllerId);
}
示例3: OnServerAddPlayer
public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
{
//UIConsole.Log ("OnServerAddPlayer " + Application.loadedLevelName);
if (CheckIfLobbyScene ())
{
base.OnServerAddPlayer (conn, playerControllerId);
if(_lobbyInfo!=null)
NetworkServer.Destroy(_lobbyInfo.gameObject);
_lobbyInfo = ((GameObject)Instantiate(lobbyInfoPrefab)).GetComponent<LobbyPlayerInfo>();
NetworkServer.Spawn(_lobbyInfo.gameObject);
}
else
{
int num = 0;
foreach (PlayerController current in conn.playerControllers)
{
if (current.IsValid)
{
num++;
}
}
if (num > this.maxPlayersPerConnection)
{
UnityEngine.Networking.NetworkSystem.EmptyMessage msg = new UnityEngine.Networking.NetworkSystem.EmptyMessage ();
conn.Send (45, msg);
return;
}
if(resetSpawnPointsOnSceneChange)
{
GameObject.Find("RespawnManager").GetComponent<RespawnPointsManager>().SetupInitialSpawnPoints();
resetSpawnPointsOnSceneChange = false;
}
Vector3 spawnPos = GameObject.Find("RespawnManager").GetComponent<RespawnPointsManager>().GetInitialSpawnPoint();
//UIConsole.Log());
GameObject player = (GameObject)Object.Instantiate(onlinePlayerPrefab,spawnPos,Quaternion.identity);
NetworkServer.AddPlayerForConnection(conn,player,playerControllerId);
//UIConsole.Log("FAILED TO ADD PLAYER");
}
}
示例4: OnServerConnect
public override void OnServerConnect(NetworkConnection conn)
{
conn.Send(MyMsgType.UpdateSeed, new StringMessage(GameController.seed));
base.OnServerConnect(conn);
}
示例5: KickPlayer
public void KickPlayer(NetworkConnection conn)
{
conn.Send(MsgKicked, new KickMsg());
}