---------------------------------------李明阳---2016/5/29---------ExitGames-Photon-Server-SDK_v3-4-31-10808------------------------
Unity客户端“框架”
PhotonEngine.cs
继承IPhotonPeerListener:
public class PhotonEngine : MonoBehaviour, IPhotonPeerListener
实现IphotonPeerListener接口
#region IPhotonPeerListener
public void DebugReturn(DebugLevel level, string message)
{
}
public void OnEvent(EventData eventData)
{
}
public void OnOperationResponse(OperationResponse operationResponse)
{
}
public void OnStatusChanged(StatusCode statusCode)
{
}
#endregion
创建Peer:
private PhotonPeer peer;
public ConnectionProtocol protocol = ConnectionProtocol.Tcp;
public string serverAddress = "127.0.0.1:4530";
public string applicationName = "MyServer";
void Awake()
{
peer = new PhotonPeer(this, protocol);
peer.Connect(serverAddress, applicationName);
DontDestroyOnLoad(this.gameObject);
}
跟踪消息队列,有消息就向服务端发送(消息传递属于异步执行)
// Update is called once per frame
void Update ()
{
if (peer != null)
peer.Service();
}
nity3D客户端框架