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

📄 connectioncontroler.java

📁 J2ME的游戏原代码!希望能帮助有需要帮助的师兄弟们!..
💻 JAVA
字号:
/*
 *通信
 *作者:肖昶
 *
*/
package fivegame;

import java.io.*;

public class ConnectionControler {

	static DataInputStream dis;
	static DataOutputStream dos;

	public static final void initConnCtrl(DataInputStream dis,
			DataOutputStream dos) {
		ConnectionControler.dis = dis;
		ConnectionControler.dos = dos;
	}

	public static final void sendChess(byte x, byte y) {
		try {
			dos.writeByte(1);
			dos.writeByte(x);
			dos.writeByte(y);
			dos.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static final void sendUserInfo(String userName, short wfs[])
			throws IOException {
		dos.writeUTF(userName);
		dos.writeShort(wfs[0]);
		dos.writeShort(wfs[1]);
		dos.flush();
	}

	public static final byte readMessageType() throws IOException,
			EOFException, InterruptedIOException {
		return dis.readByte();
	}

	public static final byte[] readChess() {
		byte chess[] = new byte[2];
		try {
			chess[0] = dis.readByte();
			chess[1] = dis.readByte();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return chess;
	}

	public static final String readUserName() {
		String name = null;
		try {
			name = dis.readUTF();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return name;
	}

	public static final short[] readUserWL() {
		short data[] = new short[2];
		try {
			data[0] = dis.readShort();
			data[1] = dis.readShort();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return data;
	}
}

⌨️ 快捷键说明

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