📄 mainform.java
字号:
package cardserver;
/**
* <p>Title: CardServer</p>
*
* <p>Description: lizhenpeng</p>
*
* <p>Copyright: Copyright (c) 2005</p>
*
* <p>Company: LP&P</p>
*
* @author lipeng
* @version 1.0
*/
import javax.microedition.lcdui.*;
import javax.microedition.io.*;
import java.util.*;
public class MainForm
extends Form implements CommandListener,Runnable
{
ServerSocketConnection server;
SocketConnection clientSocket;
Vector userList = new Vector();
private Thread thread = null;
boolean isRunning = false;
static public MainForm inst;
public MainForm()
{
super("服务器");
this.append("服务器正在运行");
try
{
server=(ServerSocketConnection)Connector.open("socket://:8070");
isRunning=true;
thread=new Thread(this);
thread.start();
}
catch(Exception e)
{
}
inst = this;
}
private void init()
throws Exception
{
setCommandListener(this);
addCommand(new Command("Exit",Command.EXIT,1));
}
public void commandAction(Command command,Displayable displayable)
{
if(command.getCommandType()==Command.EXIT)
{
CardServerMIDlet.quitApp();
}
}
public void run()
{
while(isRunning)
{
try
{
clientSocket=(SocketConnection)server.acceptAndOpen();
ClientConnection client = new ClientConnection(clientSocket);
userList.addElement(client);
new Thread(client).start();
}
catch(Exception e)
{
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -