[SNAP]
实例讲解移动
QQ
在线平台
作者:陈曦 文章来源:j2medev
简单介绍
SNAP Mobile
的架构
编写者
|
日期
|
关键词
|
陈曦
@exce4
|
2006- 4-15
|
SNAP Mobile API Http TCP J2ME
|
SNAP
的概念
SNAP
,即
Scalable Network Application Package
,翻译为
可缩放的网络应用解决方案
。
SNAP
Mobile APIs
是
Nokia
公司和
SUN
公司提供给全球众多移动游戏开发者的基于
Nokia SNAP
移动平台(像
N-Gage
™
Arena.
)和
Sun Java Wireless Toolkit (version2.3)
的一个功能强大的
J2ME
客户端的
API
开发包。
在
SNAP APIs
中提供了基于可高效拓展服务的手机多人在线游戏的开发环境,可以使开发者很方便的为程序添加网络特性,比如注册、登陆、即时通信、多人在线游戏、认证、好友列表、聊天、游戏积分排行、用户帐户和个人信息等游戏特性,大大地简化进行手机多人在线游戏
J2ME
程序的开发工作。
SNAP
Mobile
具有
三大特点:
l
具有游戏社区功能
(IMPS services)
l
具有在线游戏功能
(SNAP Game services)
l
具有交流社区功能
(Web services)
也就是说,你可根据你的项目特点有选择地进行开发。
商业应用示范
snapmobile
给出了一些与
nokia
合作的手机游戏开发商的展示:
http://snapmobile.nokia.com/n-gage/web/en/snapmobile/games.jsp
Octopi Game Development Studio
也有很好的示范,你可以浏览
http://www.octopi.com/snap.htm
从那里你能得到一个很好的概念。
到底
SNAP Mobile
是什么?
对于移动游戏开发者来说,它其实就是多人在线游戏的开发工具。通过它你可以实现手机注册、登陆、进入游戏大厅或者游戏房间进行多种模式的游戏对战。
它的构架是这样的:
对于客户端移动游戏开发者来说,只要实现了客户端访问到服务器,能发出请求,完成登陆、接收信息以及其他的一些社区功能而后登出服务器的话,基本就完成客户端的开发。
在
Nokia
的产业链中,整个开发运作流程是这样的:
可以看到
Nokia
有一整套规范的操作流程和成熟的商业运作模式。想了解得更多的话,可以自己仔细查询:
http://snapmobile.nokia.com/n-gage/web/en/snapmobile/process.jsp
只要与
Nokia
提供的服务器端模拟器完成上述功能,就可以进行
SNAP Mobile
开发,而不需要在真实的通讯网络里完成。这就大大节约了开发成本,提高效率,也使开发者能回到核心业务,集中精力在游戏开发上,而不需要再费过多的资源关注通讯的细节。
我们下面具体讲解一下
SNAP
客户端登陆模拟服务器的示例。
简单的登陆示例
下载开发工具:
1
。下载
SNAP Mobile Client SDK
:
http://www.forum.nokia.com/main/0,6566,034-1021,00.html
2
。下载
Sun Java Wireless Toolkit 2.3 Beta
:
http://java.sun.com/products/sjwtoolkit/download-2_3.html
(注意,必须要求用
Sun Java Wireless Toolkit 2.3
。安装它时候,虽然出现的还是
WTK2.2
版本字样,但不要怀疑。启动时它的界面不再是黄、红、蓝的强势界面,而且友好的浅蓝界面。)
安装完成后,接着就是启动
WTK2.3
,新建一个项目。例如:
新建
SNAPTest
项目,
Midlet
的类名为
test.HelloWorld
。保持原来的默认设置,其他的可选包都不用选择。
在设置的外部
api
包
External APIs
里面会看到一个
sm-ui-api.jar
的选项,还有一个
Bundle
的选项,都打上勾。
然后在安装
SNAPMobile
的目录下找到
samples
文件夹,把
samples\HelloWorld\src
目录下的
test
文件复制到
WTK2.3
的文件夹
WTK2.3\apps\SNAPTest\src
目录下
然后打开设置在权限许可
Permission
的地方添加访问权限的
API
:
MIDlet-Permissions: javax.microedition.io.Connector.socket
MIDlet-Permissions:javax.microedition.io.Connector.http
接着是设置用户自定义
User Defined
,在里面添加连接信息:
SNAP-Mobile-Host: localhost
SNAP-Mobile-Port: 8080
SNAP-Mobile-Protocol: http
username: test1
password: test
在安装
SNAPMobile
的目录下找到
lib
文件夹,把
sm-api.jar
复制到
WTK2.3\apps\SNAPTest\lib
目录下。然后
编译生成。
启动安装
SNAPMobile
的目录下
SNAPMobile\tools\ServerEmulator
的服务器端模拟器
emu.bat
,会出现一个
DOS
运行框,里面有发布信息,然后再运行客户端的模拟器,就会出现欢迎信息,完成登陆。
可能看完这个示例后,你对
SNAP Mobile
有了一个初步的概念。下面我们再深入一点地介绍整个
SNAP Moile
的构架和实现。
通过以下
HelloWorld.java
的主要部分
代码:
HelloWorld.java
|
public class HelloWorld extends MIDlet implements Runnable, SnapEventListener {
/***开始运行***/
public void startApp() {
/***初始化获取访问权限***/
protocol = getAppProperty("SNAP-Mobile-Protocol");
hostname = getAppProperty("SNAP-Mobile-Host");
port = Integer.parseInt(getAppProperty("SNAP-Mobile-Port"));
username = getAppProperty("username");
password = getAppProperty("password");
gameClassID = 49152;
thread = new Thread(this);
thread.start();
}
/***线程运行***/
public void run() {
try { /***创建服务器连接对象(主机名,端口号,协议)***/
comm = new ServerComm(hostname, port, protocol);
/***添加snap事件监听器到该对象***/
comm.addSnapEventListener(this);
/***统一登陆SNAP,IMPS和Web 服务器(用户名,密码,游戏类ID,显示属性)***/
comm.extendedLogin(username, password, gameClassID, null);
/***发送信息***/
comm.sendBuddyMessage(username, "Hello World!");
} catch (Exception e) { }
/***该对象移除snap事件监听器***/
comm.removeSnapEventListener(this);
/***统一登出服务器***/
comm.unifiedLogout();
}
/***处理事件***/
public void processEvents(Vector list) {
ItemList il;
for (int i=0; i<list.size(); i++) {
/***获取所有来自服务器的信息***/
il = (ItemList)list.elementAt(i);
switch(il.getInteger("id")) {
case ItemList.IMPS_IM_MESSAGE:
console.println("- IMPS_IM_MESSAGE EVENT", Console.YELLOW);
console.println(" from id: " + il.getString("fromID"), Console.WHITE);
console.println(" from name: " + il.getString("fromName"), Console.WHITE);
console.println(" location: " + il.getString("location"), Console.WHITE);
console.println(" message: " + il.getString("message"), Console.WHITE);
if (username.equals( il.getString("fromName"))) {
done = true;
console.println("Message from ourself, done!", Console.WHITE);
} else {
console.println("Message from someone else, not done.", Console.WHITE);
}
break;
}
}
}
}
|
我们可以清楚地看到,
Nokia
已经在
SNAPMobile
里面已经封装好了连接接口和连接框架。让我们登陆
SNAPMobile
服务器成为一件很简单的事情。
(具体细节可以参考《
SNAP_Mobile_HelloWorld_Tutorial_v1_0_en.pdf
》的章节)
说到连接接口和连接框架咱们就不能跳过实现
SNAP Mobile
的通信协议。
Http
和
TCP
SNAP Mobile
规范里面明确写着支持
Http
和
TCP
协议:
l
Http
使用
8080
端口;
l
TCP
使用
8976
端口;
Nokia
的服务器端模拟器提供了修改相关协议、端口的命令。
说到这里不得不向各位说明一点,目前(从
2006
年
3
月
20
日至
4
月
19
止)
Nokia官方论坛
和
snapmobile.nokia.com
总共提供了两个性能不同的服务器端模拟器,各自针对的
Demo
。
SNAP Mobile SDK
自带工具包里的
ServerEmulator
主要是针对
samples\HelloWorld
的演示,开发指南和
readme
说明上都介绍说可以在
DOS
状态通过输入
:
C:\ ServerEmulator>emu -protocol tcp –port 8976
来完成相关协议和端口的修改,可是多次尝试,均未能修改成功。而性能不稳定。但可以通过客户端模拟器添加好友名单来修改服务器端
resource\users
文件夹下的用户数据。
而
snapmobile.nokia.com
下载的
sm-serv-em
则是可以
emu <port_number>
来修改端口。虽然性能稳定,但是取消了
通过客户端模拟器修改服务器端的用户数据的功能,只能人工手动修改。
配置访问权限
从上面的上例可以知道客户端可以通过以下代码来获取本地设置的访问权限:
getAppPropert
|
protocol = getAppProperty("SNAP-Mobile-Protocol");
hostname = getAppProperty("SNAP-Mobile-Host");
port = Integer.parseInt(getAppProperty("SNAP-Mobile-Port"));
username = getAppProperty("username");
password = getAppProperty("password");
|
而访问权限的设置除了要在客户端本地设置以外,在服务器端也是需要设置的。在客户端我们将在
用户自定义
User Defined
里面添加如下信息来设置访问权限。
KEY
|
Value
|
SNAP-Mobile-Protocol
|
http
|
SNAP-Mobile-Host
|
localhost
|
SNAP-Mobile-Port
|
8080
|
username
|
test1
|
password
|
test
|
而在服务器端的设置,我们则在服务器端模拟器的
\resource
文件夹下进行:
上例可通过修改
*.cfg
配置文件的内容来修改属性和设置。
配置文件
|
Value
|
gameclasses.cfg
|
游戏类
ID
:
游戏名
|
snapserver.cfg
|
创建游戏厅:游戏厅名
|
lobbies\49152_lobbies.cfg
|
游戏厅名
|
ranking\Test\table.cfg
|
排名表
|
ranking\Test\STAT
|
用户名
积分
时间
|
同时也可以手动修改
users
文件夹下的用户数据文件来
设置用户的信息:
1000000X.dat
|
Value
|
user-id
|
1000000X
|
user-name
|
用户名
|
password
|
密码
|
buddy-list
|
好友列表
|
(具体细节参考《
SNAP_Mobile_Community_Service_Emulator_Guide_v1_0_en.pdf
》的章节)
实例讲解移动
QQ
在线平台
该平台是基于
WTK2.3
的
Demo--SNAP Mobile Sample_Community
修改而成,界面汉化,以及一些功能做了局部调整。现在做实例讲解,主要让大家能深入理解这个
SNAPMobile
的
Sample
。
看看我们要完成的的流程:
1
.初始化
2
.登陆
3
.加载信息
4
.查找用户
5
.添加好友
6
.聊天对话
7
.好友上线
8
.下线通知
9
.离开
可以根据本文档提供的源代码,逐步理解它的构架和运作机制。
1
.初始化
Community
类初始化
|
static void initialize() {
/***com.nokia.sm.ui.View初始化***/
View.initialize();
/***好友列表框架初始化***/
BuddyView.initialize();
/***软按钮初始化***/
ButtonListView.initialize();
/***发送信息框架初始化***/
Chat.initialize();
/***确认信息框架初始化***/
Dialog.initialize();
/*** 登陆框架初始化***/
Login.initialize();
/***社区在线显示初始化***/
RankingView.initialize();
}
|
2
.登陆
连接对象发送统一登陆信息
|
try {
/***
*连接对象执行extendedLogin命令发送(用户名,密码,游戏类名,在线显示属性)
*来统一登陆SNAP, IMPS和Web服务器,
*同时服务器会返回好友列表和在线显示信息给returnValues
*/
returnValues = comm.extendedLogin(
itemList.getString("user"),
itemList.getString("pass"),
itemList.getInteger("gcid"),
itemList.getString("presence")
);
} catch (Exception e) {
String msg = "" + "Cannot contact server. Please verify "
+ "that properties SNAP-Mobile-Host and "
+ "SNAP-Mobile-Port point to a SNAP Mobile "
+ "server. App will close in a few seconds.";
/***显示出错信息***/
showError(msg, true);
/***延迟10秒***/
try {Thread.sleep(10000);}
catch (InterruptedException ie) {}
}
|
3
.加载信息
获取好友列表
|
if (lastError == null && cmd.equals("extendedLogin")) {
/***获取服务器ID ***/
webSessionID = returnValues.getString("webSessionID");
impsSessionID = returnValues.getString("impsSessionID");
snapSessionID = returnValues.getString("snapSessionID");
/*** 获取用户ID***/
snapUserID = returnValues.getString("snapUserID");
/***获取好友列表***/
buddyList.set(returnValues.getList("buddyList"));
//System.out.println(snapUserID+":");
}
|
4
.查找用户
该文档是利用
rankingList
来实现在线用户显示的
|
if (errorMessage != null) {
community.showError(errorMessage, false);
} else {
list = results.getList("rankingList");
idName = "userName";
table.clear();
for (i=0; i<list.size(); i++) {
il = (ItemList)list.elementAt(i);
id = il.getString(idName);
rank = il.getInteger("rank");
score = il.getInteger("value");
//System.out.println(""+buddyList.aisAvailable.toString() );
online =community.snapUserID.equals(String.valueOf(score));
row = new TableRow(new Object[] {"" + rank, id, "" + online}, SEPARATOR_LIST);
row.setFont(TABLE_FONT);
row.setBackgroundImage(new Image[] {null, slimOn});
row.setDimension(slimOn.getWidth(), slimOn.getHeight());
table.add(row);
}
|
5
.添加好友
BuddyList
类主要实现更新列表
,添加好友
|
/*******************更新好友列表**********************/
private void updateListeners() {
notifyListeners(new Event(this, Event.ITEM_DESELECTED, null));
}
/***********************更新在线显示******************/
public synchronized void updatePresence(String name, boolean available) {
Buddy buddy = get(name);
if (buddy != null) {
aisAvailable = buddy.isAvailable();
buddy.setAvailable(available);
if (!aisAvailable && available) onlineBuddyCount++;
if (aisAvailable && !available) onlineBuddyCount--;
repaint();
updateListeners();
}
}
/****************************添加好友***********************/
public synchronized void add(Buddy buddy) {
if (buddy.isAvailable()) {
onlineBuddyCount++;
}
list.addElement(buddy);
repaint();
updateListeners();
}
/*************************检索好友***********************/
public Buddy get(int index) {
return (Buddy)list.elementAt(index);
}
/***********************获取列表长度********************/
public int size() {
return list.size();
}
/*******************提取列表上的好友名单********************/
public synchronized Buddy get(String name) {
for (int i=0; i<list.size(); i++) {
Buddy buddy = (Buddy)list.elementAt(i);
if (name.equals(buddy.getName())) {
return buddy;
}
}
return null;
}
/***************************移除好友***********************/
public synchronized void remove(String name) {
Buddy buddy = get(name);
if (buddy != null) {
list.removeElement(buddy);
if (buddy.isAvailable()) onlineBuddyCount--;
if (buddy.getMessage() != null) pendingChatCount--;
repaint();
updateListeners();
}
}
|
6.
聊天对话
BuddyList
类主要实现更新列表,获取聊天
|
/************************添加聊天**********************/
public synchronized void addChat(String name, String msg) {
Buddy buddy = get(name);
if (buddy != null) {
String s = buddy.getMessage();
if (s == null) pendingChatCount++;
buddy.setMessage(msg);
repaint();
updateListeners();
}
}
/***********************获取聊天*****************/
public synchronized String getChat(String name) {
Buddy buddy = get(name);
if (buddy != null) {
String s = buddy.getMessage();
if (s != null) pendingChatCount--;
buddy.setMessage(null);
repaint();
updateListeners();
return s;
}
return null;
}
|
7.
好友上线
BuddyList
类主要实现更新列表
,好友上线
|
/***********************更新在线显示******************/
public synchronized void updatePresence(String name, boolean available) {
Buddy buddy = get(name);
if (buddy != null) {
aisAvailable = buddy.isAvailable();
buddy.setAvailable(available);
if (!aisAvailable && available) onlineBuddyCount++;
repaint();
updateListeners();
}
}
/******************设置新列表*********************/
public synchronized void set(Vector newList) {
if (newList == null) return;
list.removeAllElements();
onlineBuddyCount = 0;
pendingChatCount = 0;
for (int i=0; i<newList.size(); i++) {
ItemList il = (ItemList)newList.elementAt(i);
add(new Buddy( il.getString("name"),
"available".equals(il.getString("status"))));
}
repaint();
updateListeners();
}
|
8
.下线通知
BuddyList
类主要实现更新列表
,好友下线
|
/***********************更新在线显示******************/
public synchronized void updatePresence(String name, boolean available) {
Buddy buddy = get(name);
if (buddy != null) {
aisAvailable = buddy.isAvailable();
buddy.setAvailable(available);
if (aisAvailable && !available) onlineBuddyCount--;
repaint();
updateListeners();
}
}
/******************设置新列表*********************/
public synchronized void set(Vector newList) {
if (newList == null) return;
list.removeAllElements();
onlineBuddyCount = 0;
pendingChatCount = 0;
for (int i=0; i<newList.size(); i++) {
ItemList il = (ItemList)newList.elementAt(i);
add(new Buddy( il.getString("name"),
"available".equals(il.getString("status"))));
}
repaint();
updateListeners();
}
|
9
.离开
登出
|
public void exit() {
synchronized (this) {
cmdList.removeAllElements();
if (isLoggedIn()) {
ItemList itemList = new ItemList();
itemList.setItem("cmd", "unifiedLogout");
executeCmd(itemList);
}
done = true;
}
main.exit();
}
if (cmd.equals("unifiedLogout")) {
/***连接对象统一登出SNAP, IMPS,和 Web Services服务器***/
comm.unifiedLogout();
}
|
以上的代码是整个移动
QQ
在线平台的主要流程,想了解得更详细的话,请看完整的源代码。
当然它的平台框架也是很严谨的,逻辑和
UI
以及各个接口间都是都是紧耦合。下面是一般
SNAPMobile
多人游戏的完整流程。
从上面可以知道,
SNAPMobile
的开发,在客户端主要是与
SNAPMobile
网关的通信,而
Nokia
已经提供了一个抽象网关的服务器端模拟器。
我们只要通过参看相关的文档,可以通过设置
Item Lists
,然后通过
il = (ItemList)list.elementAt(i)和Item Lists.getString("
Item name
")来获取服务器端的信息,而后面的附录已经收录了非同步响应数据、复合响应数据。详细的服务器信息可以查询《SNAP_Mobile_Game_Developers_Guide_For_J2ME_Clients_v2_0_en.pdf》后面的附录。
值得一提的是,
com.nokia.sm.net;
和
com.nokia.sm.ui
;以及
com.nokia.sm. util;
三个
Nokia
自己提供的外部包,其中对于界面最重要的
com.nokia.sm.ui
的开发文档,
Nokia
没有提供。因此对理解整个框架还是有点难度的。
结合开发文档以及
SNAPMobile
的
Sample
,来理解这个移动
QQ
在线平台,会感觉难度会有所减少。而这个专题的意义就是想把你带入
SNAPMobile
的开发环境,以及想减轻入门的难度。我们所做的就是和你一起踏上探索新的技术领域的征程。
小结
利用本文档提供的源代码,您可以轻松实现SNAP登陆移动QQ在线平台的过程。
编写者
|
日期
|
关键词
|
陈曦
@exce4
|
2006- 4-19
|
SNAP Mobile API Http TCP J2ME
|
附录
1
非同步响应数据
Asynchronous Response Data
IMPS Service Events
IMPS service events
|
Event data
|
ID
|
Event
|
Name
|
Type
|
301
|
IMPS_SYS_STATUS
IMPS System Status ID
|
id
|
Integer
|
status
|
Integer
|
302
|
IMPS_RESULT
IMPS Result ID
Indicates that the request was sent to the IMPS server correctly.
|
id
|
Integer
|
resultType
|
Integer
|
resultString
|
String
|
303
|
IMPS_ERROR
IMPS Error ID
Indicates an IMPS server error.
To retrieve this event data, it is necessary to set up the error handling properly.
|
id
|
Integer
|
errorCode
|
Integer
|
errorMessage
|
String
|
304
|
IMPS_RETRIEVE_RESP
IMPS Retrieve Response ID
|
id
|
Integer
|
eventType
|
String
|
gameClassID
|
Integer
|
response
|
String
|
305
|
IMPS_BUDDY_INFO
IMPS FriendInfo ID
|
id
|
Integer
|
userID
|
Integer
|
userName
|
String
|
subscription
|
String
|
306
|
IMPS_IM_MESSAGE
IMPS IM Message ID
|
id
|
Integer
|
fromUserID
|
String
|
fromUserName
|
String
|
location
|
String
|
message
|
String
|
307
|
IMPS_IM_PRESENCE
IMPS IM Presence ID Occurs if the friend is already on requestor’s friends list.
The status (presence/availability or unavailability) of friends should be updated based on this callback or on
getBuddyList
, but not based on
IMPS_BUDDY_ACC_REJ.
|
id
|
Integer
|
fromUserID
|
String
|
fromUserName
|
String
|
availability
|
String
|
presence
|
String
|
308
|
IMPS_BUDDY_REQ
IMPS Friend Request ID
|
id
|
Integer
|
fromUserID
|
String
|
fromUserName
|
String
|
message
|
String
|
309
|
IMPS_BUDDY_ACC_REJ
IMPS Friend Reply ID
Indicates whether the friend accepts or rejects the request.
|
id
|
Integer
|
fromUserID
|
String
|
fromUserName
|
String
|
accepted
|
Integer
|
message
|
String
|
310
|
IMPS_BUDDY_REVOKED
IMPS Friend Revoked ID
Indicates that a friend (for example, User A) has removed himself or herself from a Friends list (for example, User B’s Friends list). This occurs automatically when User A deletes User B from his or her Friends list (see
IMPS_BUDDY_REMOVED
). This response applies to the IMPS server only.
Note: The game developer must remove the friend from the local Friends lists, on the client.
|
id
|
Integer
|
fromUserID
|
String
|
fromUserName
|
String
|
311
|
IMPS_BUDDY_REMOVED
IMPS Friend Removed ID
Indicates that the user (for example, User A) has removed a friend (for example, User B) from his or her list. When User A removes User B from the list, the corresponding response (
IMPS_BUDDY_REVOKED
) removes User B from User A’s Friends list.
Note: The game developer must remove the friend from the local Friends lists on the client.
|
id
|
Integer
|
fromUserID
|
String
|
fromUserName
|
String
|
312
|
IMPS_OFF_HEADER
IMPS Offline Message Header ID
|
id
|
Integer
|
fromUserID
|
String
|
fromUserName
|
String
|
messageID
|
String
|
附录2 复合响应数据
(Item Lists)
Complex Response Data (Item Lists)
user list
User list
|
Type
|
Item Name
|
Type
|
Description
|
T/V
|
userID
|
String
|
The ID of this user.
|
T/V
|
userName
|
String
|
The name of this user.
|
T/V
|
userProperty
|
String
|
User property that is defined by a game developer. The developer can define its length at login through the
size
P8
parameter of
extendedLogin
1
or
loginClient
103
and change the property through
changeUserProperty
.
122
|
V
|
lobbyID
|
String
|
The ID of this lobby; returns with
findUsers
.
129SearchUsers
|
V
|
gameRoomID
|
String
|
The ID of this gameroom; returns with
findUsers
.
129SearchUsers
|
------------------
Player List
Player list
|
Item name
|
Type
|
Description
|
name
|
String
|
The user name of this player.
|
Lobby List
Lobby list
|
Item name
|
Type
|
Description
|
id
|
String
|
The ID of this lobby.
|
name
|
String
|
The name of this lobby.
|
numUsers
|
Integer
|
The number of users currently joined in this lobby.
|
numRooms
|
Integer
|
The number of rooms currently created in this lobby.
|
Gameroom List
Gameroom lists
|
Item name
|
Type
|
Description
|
id
|
String
|
The ID of this gameroom.
|
name
|
String
|
The name of this gameroom.
|
numClients
|
Integer
|
The number of clients current joined to this gameroom.
|
numPlayers
|
Integer
|
The number of players currently joined in this gameroom.
|
maxUsers
|
Integer
|
The maximum number of users allowed in this gameroom.
|
status
|
Integer
|
The status for this gameroom.
|
Friends List
Friends List
|
|
Item name
|
Type
|
Description
|
userID
|
String
|
The ID of this friend.
|
name
|
String
|
This friend’s name.
|
status
|
String
|
The subscription status of this friend. Status refers to the friend relationship:
to
= A user has requested a friend, but that user has not accepted or rejected the request yet.
from
= A user has received but has not responded to a friend request from another user.
both
= The relationship between both users is symmetrical, meaning that the user who received the request has accepted the request, so each user now appears in the other’s friends list.
|
Ranking List
Ranking list
|
|
Item name
|
Type
|
Description
|
userName
|
String
|
The name of this user.
|
rank
|
Integer
|
Ranking of the user in a given game, for example, second (
2
) or fourth (
4
) place in Lose Your Marbles.
|
value
|
Integer
|
Numeric value, such as a score or number of points.
|
posted
|
String
|
Date when the user submitted a particular value (score, number of points, and so on).
|
Stats List
Stats list
|
|
Item name
|
Type
|
Description
|
stat
|
String
|
Name of the statistic to which the list refers; for example, Winnings, Field Goals, and so on.
|
rank
|
Integer
|
Ranking of the user in a given game, for example, second (
2
) or fourth (
4
) place in Lose Your Marbles.
|
value
|
Integer
|
Numeric value, such as a score or number of points.
|
posted
|
String
|
Date when the user submitted a particular value (score, number of points, and so on).
|
Rival List
Rival list
|
|
Item name
|
Type
|
Description
|
userID
|
String
|
The ID of this rival.
|
name
|
String
|
User name of this rival.
|
userProperty
|
String
|
User property that is defined by a game developer. The developer can define its length at login through the
size
parameter of
extendedLogin
or
loginClient
and change the property through
changeUserProperty
.
|
附录
3 JAD
文件要求
properties
|
Notes
|
SNAP-Mobile-Host
|
Configurable host setting: Hostname of SNAP Mobile Gateway or of your local host if you are using the SNAP Mobile community service emulator.
Example:
SNAP-Mobile-Host: localhost
Usage: Must be passed in as the first parameter to the
ServerComm
constructor.
|
SNAP-Mobile-Port
|
Configurable port setting, typically:
80
for HTTP
8976
for TCP
Example:
SNAP-Mobile-Port: 80
Usage: Must be passed in as the second parameter to the
ServerComm
constructor.
Note: In a development environment, the JAD files for MIDlets that are using the SNAP Mobile community service emulator (instead of establishing a network connection to the community services) should use port 8080 for
http
.
|
SNAP-Mobile-Protocol
|
Configurable protocol setting: The community service emulator accepts values of
http
or
tcp
at startup.
Example:
SNAP-Mobile-Protocol: http
Usage: Must be passed in as the third parameter to the
ServerComm
constructor.
|
SNAP-Mobile-OperatorID
|
Unique number that identifies a mobile operator, typically by using a 3-digit country code followed by the 3-digit mobile operator code. (Note: This property is reserved for use by game publishers.)
Example:
SNAP-Mobile-OperatorID: 123456
Usage: If present in the JAD File, it must be passed in as the
operatorId
parameter to
ServerComm.createUser()
. Otherwise, pass
null
instead.
|