view plaincopy to clipboardpr?
public Test {
public void (String args) throws XMPPException, IOException{
XMPPConnection.DEBUG_ENABLED = true;
ConnectionConfiguration config = ConnectionConfiguration("talk.google.com",5222,"gmail.com");
ProxyInfo proxy = ProxyInfo.forHttpProxy("代理地址", 8080, null, null);//代理服务器设置 这里用http代理 具体看网络环境
//使用新工厂
config.SocketFactory(proxy.getSocketFactory);
XMPPConnection conn = XMPPConnection(config);
conn.connect;
conn.login("[email protected]", "xxxxx");
Chat chat = conn.getChatManager.createChat("[email protected]", MessageListener{
//接收信息
@Override
public void processMessage(Chat chat, Message message) {
.out.prln(message.getFrom + ":" + message.getBody);
}
});
//监听键盘输入 发送信息
BufferedReader br = BufferedReader( InputStreamReader(.in));
String line = null;
while((line = br.readLine) != null){
(line.equals(":q")){
;
}
chat.sendMessage(line);
}
conn.disconnect;
.exit(0);
}
}
public Test {
public void (String args) throws XMPPException, IOException{
XMPPConnection.DEBUG_ENABLED = true;
ConnectionConfiguration config = ConnectionConfiguration("talk.google.com",5222,"gmail.com");
ProxyInfo proxy = ProxyInfo.forHttpProxy("代理地址", 8080, null, null);//代理服务器设置 这里用http代理 具体看网络环境
//使用新工厂
config.SocketFactory(proxy.getSocketFactory);
XMPPConnection conn = XMPPConnection(config);
conn.connect;
conn.login("[email protected]", "xxxxx");
Chat chat = conn.getChatManager.createChat("[email protected]", MessageListener{
//接收信息
@Override
public void processMessage(Chat chat, Message message) {
.out.prln(message.getFrom + ":" + message.getBody);
}
});
//监听键盘输入 发送信息
BufferedReader br = BufferedReader( InputStreamReader(.in));
String line = null;
while((line = br.readLine) != null){
(line.equals(":q")){
;
}
chat.sendMessage(line);
}
conn.disconnect;
.exit(0);
}
}
上例代码级别来源网上 本人只是对代理部分进行补充 并通过调试 如果原来作者有意见话 请告诉我
最新评论