如何从Objective-C发送Minecraft服务器数据包

时间:2012-07-16 05:47:07

标签: objective-c ios5 network-protocols minecraft packets

我确实看了问题Sending Packets to Minecraft Server: Objective-C

如果他们在这里使用此链接可能是相关的:Protocol - Minecraft Server但是,他们没有使用它。他们使用wiki主要是为了获取一般信息。我引用的是创建一个新客户端。但是,当我在IRC上询问时。他们说话就像我一无所知。所以,我在这里问。

 How do i Send the packet correctly with the fields to Minecraft server?

请注意,Minecraft服务器的代码在网站上。

我的代码,连接到服务器,Minecraft服务器上的输出如下所示:

 [INFO] Disconnecting /192.168.1.4:60911: Took too long to log in
 [INFO] Disconnecting /192.168.1.4:60915: Took too long to log in
 [INFO] Disconnecting /192.168.1.4:60927: Took too long to log in
 [INFO] /192.168.1.4:60934 lost connection
 [INFO] Disconnecting /192.168.1.4:60954: Took too long to log in

如何正确发送这些数据包?

 NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
    unsigned char *ch[] = {0x02, [[defs stringForKey:@"Username"] UTF8String]};
    UInt8 i = (UInt8)ch;
    NSData *requestData = [NSData dataWithBytes:&i length:sizeof(i)];


    NSString *reqLog = [[NSString alloc] initWithData:requestData encoding:NSUTF8StringEncoding];

    [asyncsocket writeData:requestData withTimeout:-1.0 tag:0];

    //[asyncsocket readDataToData:[GCDAsyncSocket LFData] withTimeout:-1.0 tag:0];

    [asyncsocket readDataToLength:5 withTimeout:-1.0 tag:0];

    /*NSData *responseTerminatorData = [@"\n" dataUsingEncoding:NSASCIIStringEncoding];

     [asyncsocket readDataToData:responseTerminatorData withTimeout:-1.0 tag:0];*/

最终注意:IOS5是此应用程序的平台

0 个答案:

没有答案