mirek / corewebsocket Goto Github PK
View Code? Open in Web Editor NEWWeb Socket Server and Client Library for iOS and OSX. Follows Core Foundation API style.
Home Page: http://en.wikipedia.org/wiki/WebSockets
Web Socket Server and Client Library for iOS and OSX. Follows Core Foundation API style.
Home Page: http://en.wikipedia.org/wiki/WebSockets
I have been running the CoreWebSocketConsole example with the test.html client without any issues in receiving or sending messages on my development machine (Mac OS X 10.9).
However, recently when I tested it on another machine based on Mac OS X 10.6.8 (Snow Leopard), only incoming messages were received, but none of the outgoing messages were sent successfully to the test client.
A 'kCFStreamEventErrorOccurred' event is received by __WebSocketClientWriteCallBack followed by a console message that says:
' kCFStreamEventErrorOccurred (write) '
' Error Domain=NSPOSIXErrorDomain Code=32 UserInfo=0x501300 "The operation couldn't be completed. Broken pipe" '
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Ld /Users/lv/Library/Developer/Xcode/DerivedData/mySocket-eejbwkwzhnjjjkaekcmqfajzpkjk/Build/Products/Debug/CoreWebSocket.framework/Versions/A/CoreWebSocket normal x86_64
cd /Volumes/Works/MySocket/mySocket/CoreWebSocket
export MACOSX_DEPLOYMENT_TARGET=10.6
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -L/Users/lv/Library/Developer/Xcode/DerivedData/mySocket-eejbwkwzhnjjjkaekcmqfajzpkjk/Build/Products/Debug -F/Users/lv/Library/Developer/Xcode/DerivedData/mySocket-eejbwkwzhnjjjkaekcmqfajzpkjk/Build/Products/Debug -filelist /Users/lv/Library/Developer/Xcode/DerivedData/mySocket-eejbwkwzhnjjjkaekcmqfajzpkjk/Build/Intermediates/CoreWebSocket.build/Debug/CoreWebSocket.build/Objects-normal/x86_64/CoreWebSocket.LinkFileList -install_name /Library/Frameworks/CoreWebSocket.framework/Versions/A/CoreWebSocket -mmacosx-version-min=10.6 -Xlinker -no_deduplicate -framework CoreFoundation -framework CoreServices -lcrypto -single_module -compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker /Users/lv/Library/Developer/Xcode/DerivedData/mySocket-eejbwkwzhnjjjkaekcmqfajzpkjk/Build/Intermediates/CoreWebSocket.build/Debug/CoreWebSocket.build/Objects-normal/x86_64/CoreWebSocket_dependency_info.dat -o /Users/lv/Library/Developer/Xcode/DerivedData/mySocket-eejbwkwzhnjjjkaekcmqfajzpkjk/Build/Products/Debug/CoreWebSocket.framework/Versions/A/CoreWebSocket
duplicate symbol ___WebSocketFrameOpCodeCString in:
/Users/lv/Library/Developer/Xcode/DerivedData/mySocket-eejbwkwzhnjjjkaekcmqfajzpkjk/Build/Intermediates/CoreWebSocket.build/Debug/CoreWebSocket.build/Objects-normal/x86_64/WebSocket.o
/Users/lv/Library/Developer/Xcode/DerivedData/mySocket-eejbwkwzhnjjjkaekcmqfajzpkjk/Build/Intermediates/CoreWebSocket.build/Debug/CoreWebSocket.build/Objects-normal/x86_64/WebSocketClient.o
duplicate symbol ___WebSocketFrameOpCodeCString in:
/Users/lv/Library/Developer/Xcode/DerivedData/mySocket-eejbwkwzhnjjjkaekcmqfajzpkjk/Build/Intermediates/CoreWebSocket.build/Debug/CoreWebSocket.build/Objects-normal/x86_64/WebSocket.o
/Users/lv/Library/Developer/Xcode/DerivedData/mySocket-eejbwkwzhnjjjkaekcmqfajzpkjk/Build/Intermediates/CoreWebSocket.build/Debug/CoreWebSocket.build/Objects-normal/x86_64/WebSocketFrame.o
ld: 2 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I did follow your instructions step by step.
But I can't run my app with this library.
MacOS 10.12, Xcode 7.3
Hope you guide me.
based on your example i cannot run my app.
typedef enum WebSocketProtocol WebSocketProtocol;
ISO C++ forbids forward reference to 'enum' types
I'm currently working on a project that needs to communicate with a WebSocket server. I've looked at the example in the Readme.md
file and in main.c
but they both seem to be examples for creating a WebSocket listening server and not for setting up a WebSocket client.
After browsing through the headers, it seems that I need to provide a CFSocketNativeHandle
object to the creation function WebSocketClientCreate
. I'm having trouble understanding what is needed to provide the CFSocketNativeHandle
object. I was hoping someone could shed some light on this problem, and also help future users of CoreWebSocket who also want to implement a client. Thanks!
Using https://www.websocket.org/echo.html and running the example on my MacBook Pro, the connection will refuse to close.
AppDelegate.m:
#import "AppDelegate.h"
#include "CoreWebSocket/CoreWebSocket.h"
@interface AppDelegate ()
@property (weak) IBOutlet NSWindow *window;
@end
@implementation AppDelegate
void Callback(WebSocketRef self, WebSocketClientRef client, CFStringRef value) {
if (value) {
CFShow(value);
WebSocketWriteWithString(self, CFSTR("hello!"));
}
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
WebSocketRef webSocket = WebSocketCreateWithHostAndPort(NULL, kWebSocketHostAny, 6001, NULL);
if (webSocket) {
webSocket->callbacks.didClientReadCallback = Callback;
}
}
- (void)applicationWillTerminate:(NSNotification *)aNotification {
// Insert code here to tear down your application
}
@end
I tried, and the callback willRemoveClientCallback is not called. Any help with this?
Alex.
From what I've been testing it looks like a message with an even number of characters is not read properly.
I identified that the payload data for messages with even number of characters is not masked while the ones with odd number of characters are. I don't know if that makes a difference.
Is there a plan to support secure web sockets?
It was easier to create a podfile than integrate through xcode. Pull request soon.
In the README.md
explain the pros & cons of using CoreWebSocket as compared to other libraries, such as SocketRocket.
WebSocketRelease() method doesn't release because WebSocketClients retain WebSocket. WebSocket retains WebSocketClients as well.
Proposed workaround:
for (CFIndex i = 0; i < WebSocketGetClientCount(self.webSocket); ++i) { WebSocketRelease(self.webSocket); }
Large messages are received, but WebSocketFrameParse seems to only handle the first frame resulting in truncation.
It appears there was a previous attempt to fix that was reverted. Any chance this could get fixed?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.