Guest User

Untitled

a guest
Jun 21st, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. //
  2. // Tester2AppDelegate.m
  3. // Tester2
  4. //
  5. // Created by Dylan Lukes on 11/7/10.
  6. // Copyright 2010 Dylan Lukes. All rights reserved.
  7. //
  8.  
  9. #import "Tester2AppDelegate.h"
  10. #import "MHPacketDecoder.h"
  11. #import "NSStream+MHUtilities.h"
  12.  
  13. @implementation Tester2AppDelegate
  14.  
  15. @synthesize window;
  16.  
  17. - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
  18. NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
  19.  
  20. // Initialize on another thread:
  21. packetDecoder = [[MHPacketDecoder alloc] init];
  22.  
  23. NSOutputStream *outStream = [packetDecoder getOutputStream];
  24. [packetDecoder setDelegate:self];
  25.  
  26. [outStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
  27. [outStream open];
  28.  
  29. [outStream write:&(uint8_t){0x01} exactLength:sizeof(int8_t)];
  30. [outStream write:(uint8_t *)&(int32_t){OSSwapHostToBigInt32(0x02)} exactLength:sizeof(int32_t)];
  31. [outStream write:(uint8_t *)&(int16_t){OSSwapHostToBigInt16(0x08)} exactLength:sizeof(int16_t)];
  32. [outStream write:(uint8_t *)"revenant" exactLength:8];
  33. [outStream write:(uint8_t *)&(int16_t){OSSwapHostToBigInt16(0x08)} exactLength:sizeof(int16_t)];
  34. [outStream write:(uint8_t *)"password" exactLength:8];
  35. [outStream write:(uint8_t *)&(int64_t){OSSwapHostToBigInt64(0x03)} exactLength:sizeof(int64_t)];
  36. [outStream write:&(uint8_t){0x04} exactLength:sizeof(int8_t)];
  37.  
  38. [pool drain];
  39. }
  40.  
  41. - (void)packetDecoder:(id)sender didNotDecodePacket:(NSData *)packet{
  42. return;
  43. }
  44.  
  45. - (void)packetDecoder:(id)sender didDecodeLoginRequest:(int32_t)protocolVersion username:(NSString *)username password:(NSString *)password mapseed:(int64_t)mapseed dimension:(int8_t)dimension{
  46. NSLog(@"Parsed login");
  47. }
  48.  
  49. @end
Add Comment
Please, Sign In to add comment