facebookincubator / SocketRocket

A conforming Objective-C WebSocket client library.
Other
9.54k stars 2.01k forks source link

Library for Swift #205

Closed TKirmani closed 3 years ago

TKirmani commented 9 years ago

I need this library in Swift.

nickcheng commented 9 years ago

I came across a swift library called starscream in https://github.com/daltoniam/starscream But I haven't tried it yet.

theblang commented 9 years ago

+1 for Swift

Katafalkas commented 9 years ago

+1

anilanar commented 9 years ago

I converted this library to swift as a hobby, following a #PureSwift philosophy. Using Swift arrays for buffers etc., my implementation got stuck at Autobahn's performance tests. So I've decided to implement a reference type dynamic array of my own (a class instead of a struct like Swift.Array<T>). Now it is crazy fast. I will either make a pull request or put it in its own repo when I tidy it a lil bit up.

patniemeyer commented 9 years ago

@anilanar How is your Swift port going? Did you put it up anywhere? Let me know if you want any help with it...

anilanar commented 9 years ago

I started working on it, following a pure swift route was not working well performance wise, then I started managing the memory myself, calling low level stuff such as memcpy, memmove. At some point I got stuck, couldnt make it match the objective-c performance. It was 5 times less performant for some particular test cases. I guess swift runtime/compiler is not really ready for performance critical tasks.

I could be wrong though, as I've seen another swift port of SocketRocket somewhere in GitHub but I didn't take a look at it.

rossmooney commented 8 years ago

If you need something fully in Swift immediately, this may suit your needs: https://github.com/nuclearace/Socket.IO-Client-Swift

nlutsenko commented 8 years ago

Hey everyone,

Thank you for all your interest in Swift version of Socket Rocket. Let me give few updates here, share my opinion, get your opinions as well as get you excited about the future :)

Taking into account that the current SocketRocket version works from Swift (not just a broad statement, but coming from experience working on ParseLiveQuery - the immediate goal is going to be to make it more compelling in Swift, by adding support for nullability annotations and generic object collections. This also is relatively easy process, so we can get to this very fast.

Afterwards, depending on how excited you are guys, we can go and build Swift-native interface for SocketRocket that would provide waaaay cleaner interface and swift-native type support. This would still be powered by CFNetwork, but could be decoupled from it and have a pluggable network interface.

Do you have an idea/suggestion/comment? Great! Please post it here! Do you want to take a chance on implementing this? Amazing! Pull requests are very very welcome, and I'll do my best to review/guide/help/drive any implementation of this.