⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 btserver.java

📁 《开发Nokia S40应用程序》源码(8-10章) 《开发Nokia S40应用程序》源码(8-10章)
💻 JAVA
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -