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

📄 joinrepaintmsg.java

📁 基于尚学堂坦克大战的基础上开发,支持多人对战,在线聊天,坦克大战网络版.
💻 JAVA
字号:
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetSocketAddress;

public class JoinRepaintMsg implements Msg {

	int msgType = Msg.JOIN_REPAINT_MSG;

	private TankClient tc;
	
	public static int x=(int) (Math.random() * 800);

	public JoinRepaintMsg(TankClient tc) {
		this.tc = tc;
	}

	public void send(DatagramSocket ds, String IP, int udpPort) {

		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		DataOutputStream dos = new DataOutputStream(baos);
		try {
			dos.writeInt(msgType);
			byte[] buf = baos.toByteArray();
			DatagramPacket dp = new DatagramPacket(buf, buf.length,
					new InetSocketAddress(IP, udpPort));
			ds.send(dp);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	public void parse(DataInputStream dis) {
		System.out.println("客户端接收一份服务端发来JoinRepaintMsg的数据!");
		tc.join.repaint();
	}

}

⌨️ 快捷键说明

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