Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ $ npm install react-native-swift-socketio
- Click your project in the navigator on the left and go to **build settings**
- Search for **Objective-C Bridging Header**
- Double click on the empty column
- Enter **node_modules/react-native-swift-socketio/RNSwiftSocketIO/SocketBridge.h**
- Enter **../node_modules/react-native-swift-socketio/RNSwiftSocketIO/SocketBridge.h**
- Search for **Header Search Paths**
- Double Click on the column (likely has other search paths in it already)
- Enter this text at the bottom of the column $(SRCROOT)/../node_modules/react-native-swift-socketio/RNSwiftSocketIO

... That should do it! Please let me know of any issues ...
116 changes: 73 additions & 43 deletions RNSwiftSocketIO.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

14 changes: 7 additions & 7 deletions RNSwiftSocketIO/Socket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Foundation
class SocketIO: NSObject {

var socket: SocketIOClient!
var connectionSocket: String!
var connectionSocket: NSURL!
var bridge: RCTBridge!

/**
Expand All @@ -28,12 +28,12 @@ class SocketIO: NSObject {
*/

@objc func initialise(connection: String, config: NSDictionary) -> Void {
connectionSocket = connection
connectionSocket = NSURL(string: connection);

// Connect to socket with config
self.socket = SocketIOClient(
socketURL: self.connectionSocket,
opts:config as? [String : AnyObject]
options:config as? [String : AnyObject]
)

// Initialise onAny events
Expand All @@ -44,8 +44,8 @@ class SocketIO: NSObject {
* Manually join the namespace
*/

@objc func joinNamespace() {
self.socket.joinNamespace();
@objc func joinNamespace(namespace: String) -> Void {
self.socket.joinNamespace(namespace);
}

/**
Expand Down Expand Up @@ -112,7 +112,7 @@ class SocketIO: NSObject {
}

// Disconnect from socket
@objc func close(fast: Bool) -> Void {
self.socket.close(fast: fast)
@objc func disconnect() -> Void {
self.socket.disconnect()
}
}
4 changes: 2 additions & 2 deletions RNSwiftSocketIO/SocketBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ @interface RCT_EXTERN_MODULE(SocketIO, NSObject)
RCT_EXTERN_METHOD(initialise:(NSString*)connection config:(NSDictionary*)config)
RCT_EXTERN_METHOD(addHandlers:(NSDictionary*)handlers)
RCT_EXTERN_METHOD(connect)
RCT_EXTERN_METHOD(close:(BOOL)fast)
RCT_EXTERN_METHOD(disconnect)
RCT_EXTERN_METHOD(reconnect)
RCT_EXTERN_METHOD(emit:(NSString*)event items:(id)items)
RCT_EXTERN_METHOD(joinNamespace)
RCT_EXTERN_METHOD(joinNamespace:(NSString *)namespace)
RCT_EXTERN_METHOD(leaveNamespace)

@end
31 changes: 31 additions & 0 deletions RNSwiftSocketIO/SocketIOClient/NSCharacterSet.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// NSCharacterSet.swift
// Socket.IO-Client-Swift
//
// Created by Yannick Loriot on 5/4/16.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import Foundation

extension NSCharacterSet {
class var allowedURLCharacterSet: NSCharacterSet {
return NSCharacterSet(charactersInString: "!*'();:@&=+$,/?%#[]\" {}").invertedSet
}
}
6 changes: 5 additions & 1 deletion RNSwiftSocketIO/SocketIOClient/SocketAckEmitter.swift
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import Foundation

public final class SocketAckEmitter: NSObject {
public final class SocketAckEmitter : NSObject {
let socket: SocketIOClient
let ackNum: Int

Expand All @@ -34,10 +34,14 @@ public final class SocketAckEmitter: NSObject {
}

public func with(items: AnyObject...) {
guard ackNum != -1 else { return }

socket.emitAck(ackNum, withItems: items)
}

public func with(items: [AnyObject]) {
guard ackNum != -1 else { return }

socket.emitAck(ackNum, withItems: items)
}
}
2 changes: 1 addition & 1 deletion RNSwiftSocketIO/SocketIOClient/SocketAckManager.swift
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import Foundation

private struct SocketAck: Hashable, Equatable {
private struct SocketAck : Hashable, Equatable {
let ack: Int
var callback: AckCallback!
var hashValue: Int {
Expand Down
4 changes: 2 additions & 2 deletions RNSwiftSocketIO/SocketIOClient/SocketAnyEvent.swift
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

import Foundation

@objc public final class SocketAnyEvent: NSObject {
public let event: String!
public final class SocketAnyEvent : NSObject {
public let event: String
public let items: NSArray?
override public var description: String {
return "SocketAnyEvent: Event: \(event) items: \(items ?? nil)"
Expand Down
Loading