當前位置: 首頁>>代碼示例>>Java>>正文


Java Client.sendTCP方法代碼示例

本文整理匯總了Java中com.esotericsoftware.kryonet.Client.sendTCP方法的典型用法代碼示例。如果您正苦於以下問題:Java Client.sendTCP方法的具體用法?Java Client.sendTCP怎麽用?Java Client.sendTCP使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.esotericsoftware.kryonet.Client的用法示例。


在下文中一共展示了Client.sendTCP方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ChoosingCharacterState

import com.esotericsoftware.kryonet.Client; //導入方法依賴的package包/類
public ChoosingCharacterState(Client client, StateManager states)
{
	this.client = client;
	this.states = states;
	creatingDialog = new CreatingCharacterDialog(this);
	GetUserCharactersPacket getUserCharactersPacket = new GetUserCharactersPacket();
	getUserCharactersPacket.username = UserInfo.username;
	client.sendTCP(getUserCharactersPacket);
}
 
開發者ID:MMORPG-Prototype,項目名稱:MMORPG_Prototype,代碼行數:10,代碼來源:ChoosingCharacterState.java

示例2: shouldSendFromClient

import com.esotericsoftware.kryonet.Client; //導入方法依賴的package包/類
@Test
public void shouldSendFromClient() throws Exception {
    Thread.sleep(100);
    Client client = new Client();
    client.start();
    client.connect(5000, "localhost", PORT);
    client.sendTCP("WRITE[[0x0001:2:0x5050][0xFF00:2:0x10]]");
    client.close();
    Thread.sleep(200);
    //
    assertEquals(1, messages.size());
    assertEquals("[WRITE[[0x0001:2:0x5050][0xFF00:2:0x10]]]", messages.toString());
}
 
開發者ID:RBernhardt,項目名稱:homecockpit-fsuipc,代碼行數:14,代碼來源:KryoNetServerIntegrationTest.java

示例3: RemoteMinecraft

import com.esotericsoftware.kryonet.Client; //導入方法依賴的package包/類
public RemoteMinecraft(String address) {
	client = new Client(65536, 65536);
	Kryo kryo = client.getKryo();
	kryo.register(NetCreateWorldRequest.class);
	kryo.register(NetGetBiomeDataRequest.class);
	kryo.register(NetGetBiomeDataResult.class);
	kryo.register(NetBiome.class);
	kryo.register(NetBiome[].class);
	kryo.register(NetInfoRequest.class);
	kryo.register(int[].class);
	
	client.addListener(new Listener() {
		@Override
		public void received(Connection connection, Object object) {
			if (object instanceof NetGetBiomeDataResult) {
				currentResults = (NetGetBiomeDataResult)object;
				//Log.i("Received NetGetBiomeDataResult: " + currentResults);
			} else if (object instanceof NetBiome[]) {
				NetBiome[] biomes = (NetBiome[])object;
				for (int i = 0; i < biomes.length; i++) {
					if (biomes[i] != null) {
						new Biome(biomes[i].name, biomes[i].id, biomes[i].color | 0xFF000000, true);
					}
				}
			}
		}
	});
	
	client.start();
	try {
		client.connect(5000, address, 54580, 54580);
	} catch (IOException e) {
		e.printStackTrace();
	}
	
	client.sendTCP(new NetInfoRequest());
	
}
 
開發者ID:skiphs,項目名稱:AMIDST,代碼行數:39,代碼來源:RemoteMinecraft.java

示例4: doInBackground

import com.esotericsoftware.kryonet.Client; //導入方法依賴的package包/類
@Override
protected Void doInBackground() throws Exception {
    final int BUFFER_SIZE = 10000;
    Client client = new Client(BUFFER_SIZE, BUFFER_SIZE);

    client.getKryo().register(PacketLogin.class);
    client.getKryo().register(PacketLoginResponse.class);
    client.getKryo().register(PacketRequestCaptcha.class);
    client.getKryo().register(PacketCaptchaImage.class);
    client.getKryo().register(byte[].class);
    client.getKryo().register(PacketRegister.class);
    client.getKryo().register(PacketRegistered.class);
    client.getKryo().register(PacketFilesListRequest.class);
    client.getKryo().register(PacketFilesList.class);
    client.getKryo().register(String[].class);


    client.addListener(new Listener() {
        @Override
        public void received(Connection connection, Object object) {
            if (object instanceof PacketFilesList) {
                PacketFilesList response = (PacketFilesList) object;
                System.out.println("[Sync] Got files: " + response.numFiles + " | " + response.files);

                publish(new FilesListState(response));

                connection.close();
            }
        }
    });

    client.start();

    try {
        client.connect(5000, Constants.SERVER_HOST, Constants.SERVER_PORT);
    } catch (Exception e) {
        e.printStackTrace();

        return null;
    }

    Thread.sleep(1000);
    PacketFilesListRequest req = new PacketFilesListRequest();
    req.clientPrefix = this.prefix;
    
    client.sendTCP(req);


    return null;
}
 
開發者ID:Cr0s,項目名稱:Kubach,代碼行數:51,代碼來源:RequestFilesListWorker.java

示例5: doInBackground

import com.esotericsoftware.kryonet.Client; //導入方法依賴的package包/類
@Override
protected Void doInBackground() throws Exception {
    final int BUFFER_SIZE = 64000;
    Client client = new Client(BUFFER_SIZE, BUFFER_SIZE);

    client.getKryo().register(PacketLogin.class);
    client.getKryo().register(PacketLoginResponse.class);
    client.getKryo().register(PacketRequestCaptcha.class);
    client.getKryo().register(PacketCaptchaImage.class);
    client.getKryo().register(byte[].class);
    client.getKryo().register(PacketRegister.class);
    client.getKryo().register(PacketRegistered.class);
    client.getKryo().register(PacketFilesListRequest.class);
    client.getKryo().register(PacketFilesList.class);
    client.getKryo().register(String[].class);
    client.getKryo().register(PacketChangePassword.class);
    client.getKryo().register(PacketChangePasswordResponse.class);
    client.getKryo().register(PacketWLRequestRealm.class);
    client.getKryo().register(PacketWLData.class);
    client.getKryo().register(PacketAddItemToWL.class);
    client.getKryo().register(PacketBadWLItems.class);

    client.start();

    client.addListener(new Listener() { 
        @Override
        public void received(Connection connection, Object object) {
            connection.close();
        }            
    });
    
    try {
        client.connect(5000, Constants.SERVER_HOST, Constants.SERVER_PORT);
    } catch (Exception e) {
        e.printStackTrace();

        return null;
    }

    PacketAddItemToWL packet = new PacketAddItemToWL();
    packet.item = this.item;
    packet.session = this.session;
    packet.username = this.username;
    packet.prefix = ConfigManager.getInstance().getClientPrefix();
    
    client.sendTCP(packet);

    return null;
}
 
開發者ID:Cr0s,項目名稱:Kubach,代碼行數:50,代碼來源:WLAddItemWorker.java

示例6: doInBackground

import com.esotericsoftware.kryonet.Client; //導入方法依賴的package包/類
@Override
protected Void doInBackground() throws Exception {
    final int BUFFER_SIZE = 10000;
    Client client = new Client(BUFFER_SIZE, BUFFER_SIZE);

    client.getKryo().register(PacketLogin.class);
    client.getKryo().register(PacketLoginResponse.class);
    client.getKryo().register(PacketRequestCaptcha.class);
    client.getKryo().register(PacketCaptchaImage.class);
    client.getKryo().register(byte[].class);
    client.getKryo().register(PacketRegister.class);
    client.getKryo().register(PacketRegistered.class);
    client.getKryo().register(PacketFilesListRequest.class);
    client.getKryo().register(PacketFilesList.class);
    client.getKryo().register(String[].class);
    client.getKryo().register(PacketChangePassword.class);
    client.getKryo().register(PacketChangePasswordResponse.class);

    client.addListener(new Listener() {
        @Override
        public void received(Connection connection, Object object) {
            if (object instanceof PacketChangePasswordResponse) {
                PacketChangePasswordResponse response = (PacketChangePasswordResponse) object;

                publish(new ChangePasswordState(response.isSuccess));

                connection.close();
            }
        }
    });

    client.start();

    try {
        client.connect(5000, Constants.SERVER_HOST, Constants.SERVER_PORT);
    } catch (Exception e) {
        e.printStackTrace();

        return null;
    }

    PacketChangePassword pcp = new PacketChangePassword();
    pcp.username = this.username;
    pcp.session = this.session;
    pcp.newPassword = this.newPassword;
    
    client.sendTCP(pcp);
    
    return null;
}
 
開發者ID:Cr0s,項目名稱:Kubach,代碼行數:51,代碼來源:ChangePasswordWorker.java

示例7: doInBackground

import com.esotericsoftware.kryonet.Client; //導入方法依賴的package包/類
@Override
protected Void doInBackground() throws Exception {
    final int BUFFER_SIZE = 64000;
    Client client = new Client(BUFFER_SIZE, BUFFER_SIZE);

    client.getKryo().register(PacketLogin.class);
    client.getKryo().register(PacketLoginResponse.class);
    client.getKryo().register(PacketRequestCaptcha.class);
    client.getKryo().register(PacketCaptchaImage.class);
    client.getKryo().register(byte[].class);
    client.getKryo().register(PacketRegister.class);
    client.getKryo().register(PacketRegistered.class);
    client.getKryo().register(PacketFilesListRequest.class);
    client.getKryo().register(PacketFilesList.class);
    client.getKryo().register(String[].class);
    client.getKryo().register(PacketChangePassword.class);
    client.getKryo().register(PacketChangePasswordResponse.class);
    client.getKryo().register(PacketWLRequestRealm.class);
    client.getKryo().register(PacketWLData.class);
    client.getKryo().register(PacketAddItemToWL.class);
    client.getKryo().register(PacketBadWLItems.class);


    client.addListener(new Listener() {
        @Override
        public void received(Connection connection, Object object) {
            if (object instanceof PacketWLRequestRealm) {
                PacketWLRequestRealm p = (PacketWLRequestRealm) object;
                
                doCheckStep(connection, p.realm);
            } else if (object instanceof PacketBadWLItems) {
                publish(new WLCheckState((PacketBadWLItems) object));
                
                connection.close();
            }
        }
    });

    client.start();

    try {
        client.connect(5000, Constants.SERVER_HOST, Constants.SERVER_PORT);
    } catch (Exception e) {
        e.printStackTrace();

        return null;
    }

    PacketWLRequestRealm pwlrr = new PacketWLRequestRealm();
    pwlrr.username = this.username;
    pwlrr.session = this.session;
    
    client.sendTCP(pwlrr);

    return null;
}
 
開發者ID:Cr0s,項目名稱:Kubach,代碼行數:57,代碼來源:WLCheckWorker.java


注:本文中的com.esotericsoftware.kryonet.Client.sendTCP方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。