{"id":13696050,"url":"https://github.com/acmacalister/jetfire","last_synced_at":"2025-04-13T07:51:46.063Z","repository":{"id":37413220,"uuid":"19503069","full_name":"acmacalister/jetfire","owner":"acmacalister","description":"WebSocket (RFC 6455) client library for iOS \u0026 OS X","archived":false,"fork":false,"pushed_at":"2021-12-14T18:41:20.000Z","size":202,"stargazers_count":516,"open_issues_count":39,"forks_count":83,"subscribers_count":32,"default_branch":"master","last_synced_at":"2024-09-18T23:34:47.089Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/acmacalister.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-06T17:06:23.000Z","updated_at":"2024-09-10T04:50:40.000Z","dependencies_parsed_at":"2022-08-18T18:41:51.793Z","dependency_job_id":null,"html_url":"https://github.com/acmacalister/jetfire","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acmacalister%2Fjetfire","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acmacalister%2Fjetfire/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acmacalister%2Fjetfire/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/acmacalister%2Fjetfire/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/acmacalister","download_url":"https://codeload.github.com/acmacalister/jetfire/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248681493,"owners_count":21144700,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T18:00:35.884Z","updated_at":"2025-04-13T07:51:46.032Z","avatar_url":"https://github.com/acmacalister.png","language":"Objective-C","funding_links":[],"categories":["Networking"],"sub_categories":[],"readme":"Jetfire\n=======\n\nWebSocket [RFC 6455](http://tools.ietf.org/html/rfc6455) client library for iOS and OSX.\n\nJetfire is a conforming WebSocket ([RFC 6455](http://tools.ietf.org/html/rfc6455)) client library in Objective-C for iOS and OSX.\n\nJetfire also has a Swift counter part here: [Starscream](https://github.com/daltoniam/starscream)\n\n## Features\n\n- Conforms to all of the base [Autobahn test suite](http://autobahn.ws/testsuite/).\n- Nonblocking. Everything happens in the background, thanks to GCD.\n- Simple delegate pattern design.\n- TLS/WSS support.\n- Simple concise codebase at just a few hundred LOC.\n\n## Example ##\n\nFirst thing is to import the header file. See the Installation instructions on how to add Jetfire to your project.\n\n```objc\n#import \"JFRWebSocket.h\"\n```\n\nOnce imported, you can open a connection to your WebSocket server. Note that `socket` is probably best as a property, so your delegate can stick around.\n\n```objc\nself.socket = [[JFRWebSocket alloc] initWithURL:[NSURL URLWithString:@\"ws://localhost:8080\"] protocols:@[@\"chat\",@\"superchat\"]];\nself.socket.delegate = self;\n[self.socket connect];\n```\n\nAfter you are connected, there are some delegate methods that we need to implement.\n\n### websocketDidConnect\n\n```objc\n-(void)websocketDidConnect:(JFRWebSocket*)socket {\n    NSLog(@\"websocket is connected\");\n}\n```\n\n### websocketDidDisconnect\n\n```objc\n-(void)websocketDidDisconnect:(JFRWebSocket*)socket error:(NSError*)error {\n    NSLog(@\"websocket is disconnected: %@\",[error localizedDescription]);\n}\n```\n\n### websocketDidReceiveMessage\n\n```objc\n-(void)websocket:(JFRWebSocket*)socket didReceiveMessage:(NSString*)string {\n    NSLog(@\"got some text: %@\",string);\n}\n```\n\n### websocketDidReceiveData\n\n```objc\n-(void)websocket:(JFRWebSocket*)socket didReceiveData:(NSData*)data {\n    NSLog(@\"got some binary data: %d\",data.length);\n}\n```\n\nOr you can use blocks.\n\n```objc\nself.socket = [[JFRWebSocket alloc] initWithURL:[NSURL URLWithString:@\"ws://localhost:8080\"] protocols:@[@\"chat\",@\"superchat\"]];\n//websocketDidConnect\nsocket.onConnect = ^{\n    println(\"websocket is connected\")\n};\n//websocketDidDisconnect\nsocket.onDisconnect = ^(NSError *error) { \n    NSLog(@\"websocket is disconnected: %@\",[error localizedDescription]);\n};\n//websocketDidReceiveMessage\nsocket.onText = ^(NSString *text) { \n    NSLog(@\"got some text: %@\",string);\n};\n//websocketDidReceiveData\nsocket.onData = ^(NSData *data) {\n     NSLog(@\"got some binary data: %d\",data.length);\n};\n//you could do onPong as well.\n[socket connect];\n```\n\nThe delegate methods give you a simple way to handle data from the server, but how do you send data?\n\n### writeData\n\n```objc\n[self.socket writeData:[NSData data]]; // write some NSData over the socket!\n```\n\n### writeString\n\nThe writeString method is the same as writeData, but sends text/string.\n\n```objc\n[self.socket writeString:@\"Hi Server!\"]; //example on how to write text over the socket!\n```\n\n### disconnect\n\n```objc\n[self.socket disconnect];\n```\n\n### isConnected\n\nReturns if the socket is connected or not.\n\n```objc\nif(self.socket.isConnected) {\n  // do cool stuff.\n}\n```\n\n### Custom Headers\n\nYou can also override the default websocket headers with your own custom ones like so:\n\n```objc\n[self.socket setHeader:@\"Sec-WebSocket-Protocol\" forKey:@\"someother protocols\"];\n[self.socket setHeader:@\"Sec-WebSocket-Version\" forKey:@\"14\"];\n[self.socket setHeader:@\"My-Awesome-Header\" forKey:@\"Everything is Awesome!\"];\n```\n\n### Protocols\n\nIf you need to specify a protocol, simple add it to the init:\n\n```objc\n//chat and superchat are the example protocols here\nself.socket = [[JFRWebSocket alloc] initWithURL:[NSURL URLWithString:@\"ws://localhost:8080\"] protocols:@[@\"chat\",@\"superchat\"]];\nself.socket.delegate = self;\n[self.socket connect];\n```\n\n### Self Signed SSL and VOIP\n\nThere are a couple of other properties that modify the stream:\n\n```objc\n//set this if you are planning on using the socket in a VOIP background setting (using the background VOIP service).\nself.socket.voipEnabled = YES;\n\n//set this you want to ignore SSL cert validation, so a self signed SSL certificate can be used.\nself.socket.selfSignedSSL = YES;\n```\n\n### SSL Pinning\n\nSSL Pinning is also supported in Jetfire. \n\n```objc\nself.socket = [[JFRWebSocket alloc] initWithURL:[NSURL URLWithString:@\"ws://localhost:8080\"] protocols:@[@\"chat\",@\"superchat\"]];\nNSData *data = ... //load your certificate from disk\nso\nself.socket.security = [[JFRSecurity alloc] initWithCerts:@[[[JFRSSLCert alloc] initWithData:data]] publicKeys:YES];\n//self.socket.security = [[JFRSecurity alloc] initUsingPublicKeys:YES]; //uses the .cer files in your app's bundle\n```\nYou load either a `NSData` blob of your certificate or you can use a `SecKeyRef` if you have a public key you want to use. The `usePublicKeys` bool is whether to use the certificates for validation or the public keys. The public keys will be extracted from the certificates automatically if `usePublicKeys` is choosen.\n\n### Custom Queue\n\nA custom queue can be specified when delegate methods are called. By default `dispatch_get_main_queue` is used, thus making all delegate methods calls run on the main thread. It is important to note that all WebSocket processing is done on a background thread, only the delegate method calls are changed when modifying the queue. The actual processing is always on a background thread and will not pause your app.\n\n```objc\n//create a custom queue\nself.socket.queue = dispatch_queue_create(\"com.vluxe.jetfire.myapp\", nil);\n```\n\n## Example Project\n\nCheck out the SimpleTest project in the examples directory to see how to setup a simple connection to a WebSocket server.\n\n## Install ##\n\nThe recommended approach for installing Jetfire is via the CocoaPods package manager (like most libraries).\n\n## Requirements ##\n\nJetfire requires at least iOS 5/OSX 10.7 or above.\n\n## Dependencies ##\n- Security.framework\n- CFNetwork.framework\n\n## TODOs\n\n- [ ] Complete Docs\n- [ ] Add Unit Tests\n\n## License ##\n\nJetfire is license under the Apache License.\n\n## Contact ##\n\n### Austin Cherry ###\n* https://github.com/acmacalister\n* http://twitter.com/acmacalister\n* http://austincherry.me\n\n### Dalton Cherry ###\n* https://github.com/daltoniam\n* http://twitter.com/daltoniam\n* http://daltoniam.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facmacalister%2Fjetfire","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Facmacalister%2Fjetfire","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Facmacalister%2Fjetfire/lists"}