您的位置:首页 > 移动开发 > Unity3D

001_Unity3D客户端框架

2016-09-05 17:36 162 查看
001_U

---------------------------------------李明阳---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客户端框架
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  unity3d