Bluebox和Smartfox 2X是两个常用的网络通信框架。在使用它们时,可能会遇到以下问题:
localhost
1936
SmartFoxClient sfsClient = new SmartFoxClient();
sfsClient.connect("127.0.0.1", 9933);
SmartFoxClient sfsClient = new SmartFoxClient();
sfsClient.addEventListener(SFSEvent.CONNECTION, onConnection);
sfsClient.addEventListener(SFSEvent.CONNECTION_LOST, onConnectionLost);
sfsClient.addEventListener(SFSEvent.LOGIN, onLogin);
function onConnection(evt:SFSEvent):void {
if (evt.params.success) {
trace("连接成功.");
sfsClient.send(new LoginRequest("userName"));
} else {
trace("连接失败.");
}
}
function onConnectionLost(evt:SFSEvent):void {
trace("连接断开.");
}
function onLogin(evt:SFSEvent):void {
if (evt.params.success) {
trace("登录成功.");
} else {
trace("登录失败.");
}
}
通过以上解决方案,可以解决使用Bluebox和Smartfox 2X时遇到的一些问题。