btserver.java
来自「《开发Nokia S40应用程序》源码(8-10章) 《开发Nokia S40」· Java 代码 · 共 52 行
JAVA
52 行
import java.util.*;
import java.io.*;
import javax.microedition.io.*;
public class BTServer implements Runnable {
static boolean m_done;
static private StreamConnectionNotifier m_notifier;
static private Vector m_Connections;
public BTServer() {
}
public void init(Vector connections) {
m_done = false;
m_Connections = connections;
try
{
m_notifier = (StreamConnectionNotifier)Connector.open(
"btspp://localhost:" + BTConnection.CHAPTER10_UUID.toString() +
";name=Chapter10Example");
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public void run() {
StreamConnection conn = null;
while( !m_done)
{
try {
//block until connect (StreamConnectionNotifier interface)
conn = m_notifier.acceptAndOpen();
if (!m_Connections.contains(conn)) {
System.out.println("ACCEPTED NEW CONNECTION");
}
}
catch (IOException ex) {
ex.printStackTrace();
if (conn != null) {
try {
conn.close();
}
catch (IOException ex2) {
}
}
}
}
} //run
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?