smssockettest.java

来自「Socket程序」· Java 代码 · 共 97 行

JAVA
97
字号
//SMSSocketTest.java		2004/04/01	tana//该测试程序将启动3个socket端口侦听,并且能够接收短消息import javax.microedition.midlet.*;import javax.microedition.io.*;import javax.microedition.lcdui.*;import java.io.*;public class SMSSocketTest extends MIDlet implements CommandListener {    private final static String SERVER = "Server";    private final static String CLIENT = "Client";    private static String[] names = {SERVER, CLIENT};    private static Display display;    private Form f;    private ChoiceGroup cg;    private boolean isPaused;    private Server server;    private Client client;            Command exitCommand = new Command("Exit", Command.EXIT, 1);    Command startCommand = new Command("Start", Command.ITEM, 1);    public SMSSocketTest()     {        display = Display.getDisplay(this);        f = new Form("SMS with Socket Test");        cg = new ChoiceGroup("Please select peer", Choice.EXCLUSIVE, names, null);        f.append(cg);        f.addCommand(exitCommand);        f.addCommand(startCommand);        f.setCommandListener(this);	        display.setCurrent(f);    }    public boolean isPaused()     {        return isPaused;    }    public void startApp()     {        isPaused = false;    	        }        public void pauseApp()     {        isPaused = true;    }    public void destroyApp(boolean unconditional)     {        if (server != null)         {            server.stop();        }        if (client != null)         {            client.stop();        }    }    public void commandAction(Command c, Displayable s)     {        if (c == exitCommand)         {                destroyApp(true);                notifyDestroyed();        }         if (c == startCommand)         {     	  	String name = cg.getString(cg.getSelectedIndex());            	if (name.equals(SERVER))             	{	                server = new Server(this);                	server.start();            	}             	else             	{                	client = new Client(this);                	client.start();            	}        }            }    	}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?