这是RPC:
[RPC]
IEnumerator FindGameServerReq(uLobby.LobbyMessageInfo info, string zoneId)
{
Debug.Log("Client " + info.sender + " requested joinable game server.");
Debug.Log("Zone ID: " + zoneId);
var req = _instanceMgr.GetInstance(zoneId);
yield return req.WaitUntilDone();
var gameServerEndPoint = req.GetGameServerEndPoint();
Debug.Log("Informing " + info.sender + " to join game server " + gameServerEndPoint);
uLobby.Lobby.RPC("FindGameServerResp", info.sender, gameServerEndPoint);
}
这就是我调用RPC的方式:
uLobby.Lobby.RPC("FindGameServerReq", uLobby.LobbyPeer.lobby, "town");
这是错误:
Exception: Can't read from BitStream because the type safe code 'String' should have been 'Object'
uLink.BitStream.#=qaJMtkufwOBTmus4Sj1oTtg== (BitStreamTypeCode #=q0kejgO9k7qY8elenFktRag==)
uLink.BitStream._ReadObject (uLink.BitStreamCodec codec, System.Object[] codecOptions)
#=qEcomxFqHWOojBhw7H8BPzzZhTr1DAnoBEQ62wyTQ$_s=.#=qGXSr2kjU4f7Ppc8kLs_Ngw== (uLink.BitStream #=qgXeDfPNYYMJmwReOvN7L$g==, System.Object #=quKCAMLPDCdyzEzH7UPZtmg==)
#=qI8pUof4AE4hEbRq3kz45z_BPBVKqHSPhJs4bLixooWQ=.#=q0c9j_kaqqCWqjUzT6CDHZQ== (uLink.BitStream #=qQILAgzJGastvZ9EIjYcBAA==, System.Object #=qIMGdUjbLteWVoYoL7pJv6Q==)
uLobby.Lobby.#=qn$OneteGV_YoF5_9aIgusg== (.#=q$FieuT6o10Me2og7rTqd9Q== #=qkk5WAgkwWtcicPRsMf4WhQ==, Boolean #=qHhcjKXvQyV_PqtKYVSZAqA==)
显然字符串应该是字符串而不是对象。请帮忙,我已尝试过统一答案,但在那里得到答案几乎是不可能的,因为他们的网站有点矛盾。
答案 0 :(得分:0)
只需以这种方式反转参数的顺序:
IEnumerator FindGameServerReq(string zoneId, uLobby.LobbyMessageInfo info)
LobbyMessageInfo必须是RPC
中的最后一个参数