我正在尝试从 msn 交换机插座读取文本
public String readStream() {
String temp = null;
try {
temp = buffReader.readLine();
System.out.println("<<< " + temp);
} catch (Exception e) {
e.printStackTrace();
}
return temp;
}
// this method is called
public void print() {
while (socket.isConnected()) {
readStream();
}
}
当在 msn 上收到消息时,输出应该是这样的(根据http://www.hypothetic.org/docs/msn/switchboard/example_session.php)
<<< MSG bob@passport.com Bob 143\r\n
MIME-Version: 1.0\r\n
Content-Type: text/plain; charset=UTF-8\r\n
X-MMS-IM-Format: FN=Lucida%20Sans%20Unicode; EF=B; CO=ff0000; CS=0; PF=22\r\n
\r\n
Hello.
我的输出:
<<< MSG myemail@email.com MYNAME 128
<<< MIME-Version: 1.0
<<< Content-Type: text/plain; charset=UTF-8
<<< X-MMS-IM-Format: FN=Arial; EF=; CO=000000; CS=0; PF=00; RL=0;
<<<
如您所见,在此人发送另一条消息之前,我没有收到发送的消息。
输出:
<<< MSG myemail@email.com MYNAME 128
<<< MIME-Version: 1.0
<<< Content-Type: text/plain; charset=UTF-8
<<< X-MMS-IM-Format: FN=Arial; EF=; CO=000000; CS=0; PF=00; RL=0;
<<<
<<< helloMSG myemail@email.com MYNAME 127
<<< MIME-Version: 1.0
<<< Content-Type: text/plain; charset=UTF-8
<<< X-MMS-IM-Format: FN=Arial; EF=; CO=000000; CS=0; PF=00; RL=0;
<<<
那么如何解决这个问题,以便我可以阅读整个消息?