首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

小弟我学习移动开发的一个聊天程序

2012-08-24 
我学习移动开发的一个聊天程序[sizelarge]Solution ReportProtocol define and explainWe define the fol

我学习移动开发的一个聊天程序
[size=large]Solution Report
Protocol define and explain
    We define the following a simple transportation protocol which the midlet send to server:
Id_message_body
The first is the midlet’s id;
The second is the method, it can be “add”,”message”,”delete”
The third part is the message;
Id_add_MessageBody: This message will be send by midlet when he connect to the chat room.
Id_message_MessageBody: This message will be send by midlet when he send a message to other.
Id_delete_MessageBody: This message will be send by midlet when he leave the chat room.

We define a simple transportation protocol which the server send to midlet:
messageType_messageBody
The first is the message Type, it can be “private”,”message”
The second is the messageBody.
Private_messageBody: This information will be send only for this person, and it will displayed at the top, for example, the previous connected person’s information.
Message_messageBody: This information will be send for all the person, and it will displayed as a chat history below the private message. For example, the other person’s chat message.
Server side implementation
  We implement a servlet which will startup when the server is started, and the servlet will initialize a Thread  which listened in 8000(You can configure it in configuration file web.xml). Every time when a new connection come in, a new Thread will create to deal with the message. And we maintain a Socket collection which hold all the socket connection.
Midlet client implementation
     When the program initialized, it will construct a SocketConnection, and when user click the connect, we will create two thread, one is the writeThread which will write the message queue’s message to server, the other is the readThread, which will read the message from server, and display it in corresponding location according to the message type.
When the user click the send button, the message will be put into message queue, and it will notify the writeThread to write it to the server.
When the user click the exit button, the readThread and the writeThread will be stoped, and also we will release some resources, for example the socket’s InputStream and OutputStream, and also the SocketConnection.
[/size]











1 楼 asialee 2009-08-03   对不起呀,这个是我给一个留学的同学做的,大家就勉强的看吧。也随便锻炼锻炼英文,呵呵。 2 楼 ccxw1983 2009-08-03   确实不错哦,英文好啊 3 楼 asialee 2009-08-04   做的时候感觉虽然J2ME里面的线程比较难控制,我的里面线程控制有点问题,呵呵。 4 楼 lordhong 2009-08-04   asialee 写道做的时候感觉虽然J2ME里面的线程比较难控制,我的里面线程控制有点问题,呵呵。

嗯, J2ME的thread还真麻烦... 5 楼 wayfarer 2009-08-04   怎么麻烦了?我觉得还好啊

lordhong 写道asialee 写道做的时候感觉虽然J2ME里面的线程比较难控制,我的里面线程控制有点问题,呵呵。

嗯, J2ME的thread还真麻烦...
6 楼 asialee 2009-08-04   wayfarer 写道怎么麻烦了?我觉得还好啊

lordhong 写道asialee 写道做的时候感觉虽然J2ME里面的线程比较难控制,我的里面线程控制有点问题,呵呵。

嗯, J2ME的thread还真麻烦...


Java SE和EE都开发过,但ME没有开发过,我稍微看了一下,然后按照开发java程序的思想写的,但感觉稍微不一样。
7 楼 youngmaster 2009-08-04   看了朋友的作品,感觉真好...期待朋友更多的精彩! 8 楼 asialee 2009-08-04   youngmaster 写道看了朋友的作品,感觉真好...期待朋友更多的精彩!
是在说我吗? 要是我的话,先谢谢了。
9 楼 asialee 2009-08-05   这个是我用了大概3天时间写的,还是比较仓促。当感觉思想是相通的。 10 楼 asialee 2009-08-05   这么多人下载了,小弟感谢一下,也欢迎大家提点意见。 11 楼 java.lang.Object 2009-08-05   楼主netbeans的代码字体调得真大。 12 楼 asialee 2009-08-06   java.lang.Object 写道楼主netbeans的代码字体调得真大。
字体调大了省眼睛呀,呵呵。
13 楼 asialee 2009-08-17   写了这么一个烂程序被下载了上千次,我以后还会上传我的一些小程序的,不过质量会更好的。 14 楼 菩萨Lu 2010-05-31   刚开始接触j2me,拿走研究学习了,thx 15 楼 asialee 2010-06-01   菩萨Lu 写道刚开始接触j2me,拿走研究学习了,thx
感谢一下,写的不是很好,欢迎交流。

热点排行