Java利用MSNP协议登录MSN
请参见上一篇文章,登录MSN协议
具体Java实现:
命令序列:<<代表发送,>>代表结果
1.连接DS(Dispatcher Server),得到NS(Notification Server)
<<VER 1 MSNP18 CVR0
>>VER 1 MSNP18
<<CVR 2 0x0804 winnt 5.1 i386 MSNMSGR 14.0.8089.0726 msmsgs yourAccount
>>CVR 2 14.0.8089 14.0.8089 14.0.8089 http://msgruser.dlservice.microsoft.com/download/0/9/7/0974F7CD-D082-46FE-922D-806670345793/zh-chs/wlsetup-cvr.exe http://download.live.com/?sku=messenger
<<USR 3 SSO I yourAccount
>>XFR 3 NS 207.46.124.86:1863 U D
private String dsHost = "64.4.9.254";//ds host
private String nsHost;//ns host
private int port = 1863;//port
private int trId = 1;//命令序列号
private String ticketToken;//在获取联系人时用
//得到向MSN服务器发送的命令
private String getMSNCommand(String cmd, String ... args) {
StringBuilder sb = new StringBuilder();
sb.append(cmd).append(' ');
sb.append(trId++).append(' ');
for (int i = 0; i < args.length; i++) {
if (i < args.length - 1) {
sb.append(args[i]).append(' ');
} else {
sb.append(args[i]);
}
}
sb.append("\r\n");
return sb.toString();
}
//初始化NS地址
private void initNSHost() throws TelnetException {
NonBlockTelnetClient client = new NonBlockTelnetClient(dsHost, port);
client.connect();
String cmd = getMSNCommand("VER", "MSNP18", "CVR0");
client.sendCommand(cmd);
String resp = client.getOutputByLine();
System.out.println("resp=" + resp);
cmd = getMSNCommand("CVR", "0x0804", "winnt", "5.1", "i386", "MSNMSGR", "14.0.8089.0726", "msmsgs", username);
client.sendCommand(cmd);
resp = client.getOutputByLine();
System.out.println("resp=" + resp);
cmd = getMSNCommand("USR", "SSO", "I", username);
client.sendCommand(cmd);
resp = client.getOutput
相关文档:
今天我学习了徐老师讲的Hiberbate缓存知识,我上课做了简单的笔记:
缓存类型
一.事务范围:位于当前工作单元,不能并发访问
二.进程范围:多个工作单元共享,可并发访问,可存储实例本身也可存散列数据,然后在
& ......
66. EJB容器提供的服务
主要提供声明周期管理、代码产生、持续性管理、安全、事务管理、锁和并发行管理等服务。
67. EJB规范规定EJB中禁止的操作有哪些?
1.不能操作线程和线程API(线程API指非线程对象的方法如n ......
java去除字符串中的空格、回车、换行符、制表符
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class StringUtil {
public static void replaceBlank()
{
Pattern p = Pattern.compile("\\s*|\t|\r|\n");
String str="I am a, I am Hello ok, \n new line ffdsa!";
System.out.p ......
Java面试中,最常被人问到的几个问题:
1. java.util.*包的UML结构图。
2. Vector和ArrayList、LinkedList区别 Hashtable 和 HashMap之间的区别
3. String、StringBuffer,StringBuilder之间区别。
--回答--
1.
Collection
|
|_List
| |_LinkedList
| | ......
this
对象本身。public class ThisTest {
ThisTest tTest;
public ThisTest(){
tTest = this;
}
public void test(){
System.out.println(this);
}
public static void main(String arg[]){
new ThisTest().test();
}
}
成员方法引用。
成员变量引用。public class ThisTest {
String name ......