Giter Club home page Giter Club logo

nativescript-socketio's Introduction

npm npm Build Status

nativescript-socketio

Note This currently does not yet support Socket:IO v3.x

Android

V3 Support

iOS

V3 Support

Usage

{N} v7+

npm install @triniwiz/nativescript-socketio

{N} v6<

npm install nativescript-socketio

NativeScript Core

Set connection string and options then connect

var SocketIO = require('nativescript-socketio').SocketIO; 
var socketIO = new SocketIO(url, opts);

Alternatively:

import { SocketIO } from 'nativescript-socketio';
var socketIO = new SocketIO(url, opts);

Connect to server

socketIO.connect()

Send data to the server

socketIO.emit(event,data)

Listen for data

socketIO.on(event,callback)

Set instance

new SocketIO(null,null,oldInstance)

Angular

// app.module.ts
import { SocketIOModule } from "nativescript-socketio/angular";

@NgModule({
  imports: [
    SocketIOModule.forRoot(server),
  ]
})
// app.component.ts
import { Component, OnInit, OnDestroy } from "@angular/core";
import { SocketIO } from "nativescript-socketio";

@Component({
  // ...
})
export class AppComponent implements OnInit, OnDestroy {
  constructor(private socketIO: SocketIO) { }

  ngOnInit() {
    this.socketIO.connect();
  }

  ngOnDestroy() {
    this.socketIO.disconnect();
  }
}
// test.component.ts
import { Component, OnInit, NgZone } from "@angular/core";
import { SocketIO } from "nativescript-socketio";

@Component({
  // ...
})
export class TestComponent implements OnInit {
  constructor(
    private socketIO: SocketIO,
    private ngZone: NgZone
  ) { }

  ngOnInit() {
    this.socketIO.on("test", data => {
      this.ngZone.run(() => {
        // Do stuff here
      });
    });
  }

  test() {
    this.socketIO.emit("test", { test: "test" });
  }
}

Running Demo

Start socketio server

cd demo/demo-server
npm install
node app

Api

Method Default Type Description
constructor(url) void Creates a SocketIO instance with a url
constructor(url, options:{}) void Creates a SocketIO instance with url and options
constructor(null,null,nativeSocket) void Creates a SocketIO instance from a native socket instance
connect() void Connect to the server.
disconnect() void Disconnects the socket.
connected() boolean Checks if the socket is connected
on(event: string,(data: Object , ack? : Function)) Function Adds a handler for a client event. Return a function to remove the handler.
once(event: string,(data: Object , ack? : Function)) Function Adds a single-use handler for a client event. Return a function to remove the handler.
off(event: string) void Removes handler(s) based on an event name.
emit(event: string,data: {},ack?: Function) void Send an event to the server, with optional data items.
joinNamespace(name: string) SocketIO Return SocketIO instance with the namespace
leaveNamespace() void Call when you wish to leave a namespace and disconnect this socket.

Example Image

socketio

nativescript-socketio's People

Contributors

cayan avatar dimitartodorov avatar donburgess avatar gogoout avatar jogboms avatar nathanwalker avatar roblav96 avatar triniwiz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

nativescript-socketio's Issues

r.removeListener is not a function

Hello, i am trying to remove a emit function with removeListener but i getting an error:

System.err: TypeError: r.removeListener is not a function System.err: File: "file:///data/data/org.nativescript.application/files/app/app.js, line: 1, column: 6442

I tried to declare "off" function in socketio.t.ds file but still, it does not work.
Here is the basic code:

socketIO = new SocketIO(url, options);
socketIO.removeListener('hello');  //socketIO.off('hello')
socketIO .on('hello',function(data){
})

Nativescript-socket io is not connecting to node server

Hi all,

I have clone the project and ran it but it did not connected with the server. I have used node server but it failed to connect.Please have look at the code.

Node js :

var server = http.createServer(function(req,res){
res.end('hello node');
}).listen(8008, function(){
console.log('HTTP Express server listening on port 8008');
})

var sockerIO = require('socket.io')(server);

sockerIO.on('connection',function(socket){
console.log("socket "+socket);
})

Nativescript :

let socketIO;
const server = 'http://localhost:8008';

socketIO = new SocketIO(server, {})
socketIO.connect();

When we call connect() function , actually it should fire connection event , which will be listening on server. But it's not opening connection with server.Help me out please

Demo failed (Android)

Hi triniwiz,
I can not run the demo with cloned source code.
Steps:

  • start demo server (succesfull)
  • tns run android
    Error found:
    Found peer TypeScript 1.8.10
    app/login.ts(2,24): error TS2307: Cannot find module 'nativescript-socketio'.
    app/main-page.ts(5,24): error TS2307: Cannot find module 'nativescript-socketio'.

I also encounter this issue with my project using nativescript-socketio npm.
Please help me to resolve it.
Many thanks

IOS: TypeError: this.socket.emitWithAckWithItems

When trying to call emit with a callback, it report back the error.

IOS: TypeError: this.socket.emitWithAckWithItems

After reviewing the POD code seems that the right name is

IOS: TypeError: this.socket.emitWithAckWith

I corrected this on typing for ios on the plugin, but even after correction I started to get.

TypeError: emit is not a function

IOS receiving json with parentheses !!!

Did you verify this is a real problem by searching the NativeScript Forum and the other open issues in this repo?

YES

Tell us about the problem

Please, ensure your title is less than 63 characters long and starts with a capital
letter.

I use socio.io Server and when i emit event from server i recive :

(
{
"auth_id" = 687019;
}
)

no problem with android i receive :

{
"auth_id" = 687019;
}

Which platform(s) does your issue occur on?

iOS

Please provide the following version numbers that your issue occurs with:

  • CLI: 4.1.0
  • Cross-platform modules: "tns-core-modules": "^4.1.0",
  • Runtime(s):
    "tns-android": {
    "version": "4.1.3"
    },
    "tns-ios": {
    "version": "4.1.1"
    }
  • Plugin(s): (look for the version number in the package.json file of your
    project)
//server.js
const http = require("http");
const server = http.createServer();
const io = require("socket.io")(server);

io.on("connect", (socket) => {
socket.emit("auth_id", {auth_id: 123});
});

//IOS
socketIO.on("auth_id", (data) => {
        console.log("AUTHORISATION ID :");
        console.log(data);
        //output
(
{
"auth_id" = 123;
}
)

Thnk you :)

iOS Demo app issues

The android demo app seems to work fine. I am having a couple of issues with the iOS demo app. It starts and connects to the server but there is a few errors and it doesn't send messages or get the list of previously sent messages to display on screen.

This error is appears just after the build is completed. Followed by a dump.
assertion failed: 15F34 13E230: libxpc.dylib + 71506 [6F98A9DA-B46E-3A2B-88D4-92F1EC77477F]: 0x7d

Here is the iOS demo app connection to the server.

Joined Namespace: /
User Connected

Here is the login followed by another error.

Login:  (
            {
            userList =         (
                            {
                    username = Osei;
                }
            );
        }
    )
: CONSOLE LOG file:///app/tns_modules/nativescript-socketio/socketio.js:28:24: Event: getMessages
 --- last message repeated 3 times ---
: (Error) MC: MobileContainerManager gave us a path we weren't expecting; file a radar against them
    Expected: /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
    Actual: /Users/username/Library/Developer/CoreSimulator/Devices/4234F2B9-8FF7-4645-AB78-AA01434D9FB6/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
    Overriding MCM with the one true path

When trying to send a message the server throws this error.

Missing error handler on 'socket'.
TypeError: cb is not a function
    at Socket.<anonymous> (/Users/username/Documents/Joel/Code/apps/Nativescript/nativescript-socketio/demo/demo-server/app.js:29:9)

Any ideas what is going on?

ReferenceError: io is not defined

files.zip
I've create a chat component in my project and using this library to communicate with a web socket server.

This is the stacktrace when I run the app:

java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: 

[files.zip](https://github.com/triniwiz/nativescript-socketio/files/579281/files.zip)




Error calling module function 

Error calling module function 

Error calling module function 

Error calling module function 

ReferenceError: io is not defined
File: "/data/data/org.nativescript.groceries/files/app/tns_modules/nativescript-socketio/socketio.js, line: 2, column: 14

StackTrace: 
	Frame: function:'', file:'/data/data/org.nativescript.groceries/files/app/tns_modules/nativescript-socketio/socketio.js', line: 2, column: 15
	Frame: function:'require', file:'', line: 1, column: 266
	Frame: function:'', file:'/data/data/org.nativescript.groceries/files/app/pages/chat/chat.component.js', line: 14, column: 16
	Frame: function:'require', file:'', line: 1, column: 266
	Frame: function:'', file:'/data/data/org.nativescript.groceries/files/app/app.module.js', line: 17, column: 24
	Frame: function:'require', file:'', line: 1, column: 266
	Frame: function:'', file:'/data/data/org.nativescript.groceries/files/app/main.js', line: 3, column: 20
	Frame: function:'require', file:'', line: 1, column: 266

problems on iOS

There is a problem with sending / receiving messages on iOS.
For example this piece of code:
on client:

this.socket.emit("string", "SOME STRING");

on server:

socket.on('string', (value: string) => {
    console.log("Received string from client: " + value);
}

writes to console this: Received string from client: undefined

The same problem is observed on sending / receiving JSON objects and on both direction: from client to server and vise versa

Full example of this problem is available at https://github.com/AlexanderRay/socketIoWithIosIssue

Error in main file

Hi Mr. Osei,

I'm trying use the plugin in a project, but get this message when i try compile the app.

java.lang.RuntimeException: Unable to start activity ComponentInfo{org.nativescript.chat/com.tns.NativeScriptActivity}: com.tns.NativeScriptException:
Calling js method onCreate failed

ReferenceError: io is not defined
File: ", line: 1, column: 265

StackTrace:
Frame: function:'', file:'/data/data/org.nativescript.chat/files/app/tns_modules/nativescript-socketio/socketio.js', line: 9, column: 15
Frame: function:'require', file:'', line: 1, column: 266
Frame: function:'', file:'/data/data/org.nativescript.chat/files/app/pages/inicio/main-page.js', line: 1, column: 76
Frame: function:'require', file:'', line: 1, column: 266
Frame: function:'global.loadModule', file:'/data/data/org.nativescript.chat/files/app/tns_modules/globals/globals.js', line: 19, column: 16
Frame: function:'resolvePageFromEntry', file:'/data/data/org.nativescript.chat/files/app/tns_modules/ui/frame/frame-common.js', line: 72, column: 40
Frame: function:'Frame.navigate', file:'/data/data/org.nativescript.chat/files/app/tn

So check the plugin code and actually I did not find where it is called the "io" object in the main files

import common = require('./socketio.common');
import jsonHelper = require('./helpers/jsonHelper');
import app = require("application");
const Emitter = io.socket.emitter.Emitter; //When is io called? D:
const IO = io.socket.client.IO;
const Socket = io.socket.client.Socket;
const Ack = io.socket.client.Ack;

I don't know if is my mistake, honestly do not know much about how it works nativescript , but I can not make the library work.

Thanks in advance.

PD: Sorry for my pretty ugly english.

Cannot find namespace 'io'

Hi , i was trying out the demo-ng and i've got this error while executing : tns run android .

node_modules/nativescript-socketio/socketio.android.d.ts(3,23): error TS2503: Cannot find namespace 'io'

can you help please

Module not found

I was looking for exactly this module, I tried to use but is not working.

$ tns create sample
$ cd sample/
$ npm install nativescript-socketio

In my main-page.ts:

import SocketIO = require('nativescript-socketio');

"Cannont find module 'nativescript-socketio' "

Nativescript-socketio not connecting to sails server.

I'm having issues trying to use this library with sails server. I'm guessing the socket is closed before connection is established.

Here is an extract of my code
private socketIO: SocketIO;
private versionString: string;
static VERSION: string = "__sails_io_sdk_version";
static PLATFORM: string = "__sails_io_sdk_platform";
static LANGUAGE: string = "__sails_io_sdk_language";
constructor(private router: Router) { }
ngOnInit() {
this.generateVersionString(['0.11.0', 'android', 'java']);
console.log(this.versionString);
this.socketIO = new SocketIO('https://#####-####.c9users.io:1337', {
query: this.versionString,
useCORSRouteToGetCookie: false
});
this.socketIO.on('connect', function(data) {
console.log("hey....");
});
this.socketIO.on('connect_error', function(data) {
console.log('nawa ooooooo');
console.log(data);
});
this.socketIO.connect();
}
generateVersionString(sdkInfo: Array<string>): void {
this.versionString = LoginComponent.VERSION + "=" + sdkInfo[0] + "&" +
LoginComponent.PLATFORM + "=" + sdkInfo[1] + "&" +
LoginComponent.LANGUAGE + "=" + sdkInfo[2];
}

Subject can´t emit changes in callback

I am not sure if is an nativescript-sockeio error or a Nativescript error. For example:

    this..ws.on("new", (response) => {

      this._list= response.list;
     this._listSubjet$.next(this._list);

    });

how to use emit/on callback data ack in js ?

if the callback argument is an ack how do we parse it to js object ?
socketIO.on('login', function (data) { console.log("LoginSuccess: ", data); <= ack })
i would like to access data properties like:
console.log("LoginSuccess: ", data.username);

Socket.io connectParams if pass undefined crash

SocketIOModule.forRoot('http://192.168.1.181:3011', {
    connectParams: { token: BackendService.token}
}),

i solve with

        SocketIOModule.forRoot('http://api.baskonus.abdullahsargin.com.tr', {
            connectParams: { token: (BackendService.token || '') }
        }),

if you pass token undefined you give
please add param undefined control.
I spent at least 4 hours to find this error

I opened this error for documentation purposes.
you can turn it off at any time

*** JavaScript call stack:
(
0 initWithSocketURLConfig@[native code]
1 SocketIO@file:///app/tns_modules/nativescript-socketio/socketio.js:35:82
2 socketIOFactory@file:///app/tns_modules/nativescript-socketio/angular/index.js:8:35
3 _createProviderInstance$1@file:///app/tns_modules/@angular/core/bundles/core.umd.js:9321:38
4 resolveNgModuleDep@file:///app/tns_modules/@angular/core/bundles/core.umd.js:9284:46
5 createClass@file:///app/tns_modules/@angular/core/bundles/core.umd.js:10236:151
6 createDirectiveInstance@file:///app/tns_modules/@angular/core/bundles/core.umd.js:10117:31
7 createViewNodes@file:///app/tns_modules/@angular/core/bundles/core.umd.js:11339:59
8 createRootView@file:///app/tns_modules/@angular/core/bundles/core.umd.js:11253:20
9 callWithDebugContext@file:///app/tns_modules/@angular/core/bundles/core.umd.js:12288:30
10 create@file:///app/tns_modules/@angular/core/bundles/core.umd.js:9597:43
11 bootstrap@file:///app/tns_modules/@angular/core/bundles/core.umd.js:5119:46
12 forEa<\M-b\M^@\M-&>
)
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'

IOS : WebSocket.swift "characters" is deprecated !

Hello,

I read this msg when the app compile :

PROJECT_NAME/platforms/ios/Pods/StarscreamSocketIO/Source/WebSocket.swift:668:37: warning: 'characters' is deprecated: Please use String or Substring directly if headerSecKey.characters.count > 0 {

There is no error momently, the websocket work, but maybe this error come from ?? #61

Thank you

socketIO don't connect to server on IOS

I can't do a connection to server when the platform is IOS but on android with the same code I can get the connection.

	"tns-ios":   "version": "3.2.0"

	"nativescript-socketio": "^2.4.0",

I got the message when I add the ios platform:

platforms/ios/Pods/Socket.IO-Client-Swift/Source/WebSocket.swift:118:28: warning: when calling this function in Swift 4 or later, you must pass a '()' tuple; did you mean for the input type to be '()'?
public var onConnect: ((Void) -> Void)?
^~~~~~
()

Demo App not running on android

Hi,

due to problems with the plugin on ios (see #26), I decided to check, if I have the same issues on android to specify if it is more related to my sources or the native part.

So first I tried to run my app on an android emulator, which resulted in problems in the require of the plugin:

image

So I decided to give the demo app a try. Cloned the repo, started server as documented and switched to the app. Also here I followed the two steps from docs, which made a successfull built. But trying to run the demo resulted in:

image

I'm outta luck on my side.

Can't find variable: SocketIOClient

Attempting to get this library working with Nativescript + Vue. However, it errors instantly with ReferenceError: Can't find variable: SocketIOClient

This occurs with only these two lines of code inserted...

var SocketIO = require('nativescript-socketio').SocketIO;
var socketIO = new SocketIO('http://localhost:5000');

I have also tried this with the destructured import, and that fails with the same error.

I am using the following versions...

  • Xcode 9.2
  • nativescript-socketio 2.4.0

Image and/or video stream ?

Is there a way to send images or video throug the socket ? basically as a stream ?
i figured it out how to handle base64 images but it's quite heavy for big ones.

iOS: Socket.IO-Client-Swift error on build

Hi. When I'm trying to run app with nativescript-socketio plugin, i get an error during building process:

.../platforms/ios/Pods/Socket.IO-Client-Swift/Source/SocketIOClientConfiguration.swift:28:62: error: 'Generator' has been renamed to 'Iterator'
    public typealias Generator = Array<SocketIOClientOption>.Generator
                                                             ^~~~~~~~~
                                                             Iterator
Swift.Collection:3:22: note: 'Generator' has been explicitly marked unavailable here
    public typealias Generator = Self.Iterator
                     ^

After changing pod 'Socket.IO-Client-Swift', ‘8.0.2’ to pod 'Socket.IO-Client-Swift', ‘8.3.0’ in Podfile application starts normally.
Could you update the version of Socket.IO-Client-Swift?

Can't find variable: SocketIOClient

I get this when run the demo app on iOS 9.3 simulator:
file:///app/tns_modules/nativescript-socketio/socketio.js:33:49: JS ERROR ReferenceError: Can't find variable: SocketIOClient

Error with feathersjs socketioclient

Hi
I use feathersjs for real-time backend it provides a package for client called featherjs/socketio-client which require socket.io-client io property which is not working with nativescript socketio.

Please help

trouble with Xcode upgrade 8.0

i had to update the podfile to make it work with Xcode 8.0
pod 'Socket.IO-Client-Swift', '~> 8.0.0'
could you update the podfile ?

How to use socket.io through all pages of a NS app

Hi,

i have successfully implemented nativescript + socket.io chat.

Problem is that my app has several pages (and one of them is the chat interface). How can i catch socket.io events in any page, and then propagate this event to the other pages ? Typically, i would like that if a user receives a chat msg while he is not on the chat page, that msg would be dispatched to the chat page (or at least have some notification about it).

Thanks very much in advance. I am using plain JS and NativeScript

IOS: emit JSON object

Hi.
I've got an error when trying to run demo app on iOS.
After emitting 'add user' with JSON object

socketIO.emit('add user', { username:  pageData.get('username') });

demo-server throws an error:

.../socketio/demo/demo-server/app.js:20
		socket.username = data.username;
		                      ^

TypeError: Cannot read property 'username' of undefined
    at Socket.<anonymous> (.../socketio/demo/demo-server/app.js:20:25)
    at emitNone (events.js:86:13)
    at Socket.emit (events.js:185:7)
    at .../socketio/demo/demo-server/node_modules/socket.io/lib/socket.js:503:12
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)

at this lines of code:

socket.on('add user', function (data) {
		...
		socket.username = data.username;
		...
	})

Looks like JSON data is not transmitted through socket.

Failed to find module: "nativescript-socketio"

Failed to find module: "nativescript-socketio", relative to :/app/tns_modules/ ..

I try
tns plugin add nativescript-socketio and
npm install nativescript-socketio
tns version: 2.2.1
nodejs v5.7.0
Ubuntu 16.4

IOS emitting JSON Objects

Be aware that JSON objects will crash your application when trying to send through IOS.

This is because the data is not being marshalled to an NSDictionary object at this time. One of many work arounds is to JSON.stringify() your data before emitting.

Update for tns-android 4.1.3 & tns-ios 4.11

when you update android 4.1.3

run debug

<=========----> 76% EXECUTING [1m 50s]
> :app:transformDexArchiveWithExternalLibsDexMergerForDebug
23:57:59 - File change detected. Starting incremental compilation...

D8: Program type already present: okhttp3.internal.ws.RealWebSocket$1

FAILURE: Build failed with an exception.

typo in podfile

pod 'Socket.IO-Client-Swift', '~> 8.0.0' instead of pod 'Socket.IO-Client-Swift', '~> 8.0.0

Socket.IO debug

Hi. Tell me how to enable logging and debugging in nativescript-socketio. Is it possible to print all debug info into console?
According to Socket.IO docs logging is turn on with localStorage.debug property in browser.
But how it can be done in Nativescript?

on TNS 3.0.1 its breaking my app

i did a normal install
tns plugin add nativescript-socketio that made my app build fail! then i did
tns plugin remove nativescript-socketio and did an npm install, but it still wont build my app now i tried a new project run it then added tns socketio and the new app failed to build!! removed it and the app run!
is it meant to run on nativescript 3.0.1??? pliz help i need socketio

Use Swift 2.3 branch for pod file

I've been experimenting with attempts to get this to build on ios10 and xcode8. This is the pod spec you want to use:

pod 'Socket.IO-Client-Swift', :git => 'https://github.com/socketio/socket.io-client-swift.git', :branch => 'swift2.3'

When asked to convert Swift code in xcode choose 2.3.

Based off this research:
socketio/socket.io-client-swift#492

I get this error when trying to install the way it is currently:

[!] Unable to satisfy the following requirements:

- `Socket.IO-Client-Swift (~> 8.0.0)` required by `Podfile`

None of your spec sources contain a spec satisfying the dependency: `Socket.IO-Client-Swift (~> 8.0.0)`.

You have either:
 * out-of-date source repos which you can update with `pod repo update`.
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile.

Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default.

Error on iOS build after plugin added

Getting this error after trying to create my running project for iOS.

Installing pods...
Analyzing dependencies
[!] CocoaPods could not find compatible versions for pod "Socket.IO-Client-Swift":
In Podfile:
Socket.IO-Client-Swift (~> 10.3.1)

Socket.IO-Client-Swift (~> 11.1.3)

Socket.IO-Client-Swift (~> 11.2.1)

Socket.IO-Client-Swift (~> 11.3.1)

Socket.IO-Client-Swift (~> 9.0.1)

None of your spec sources contain a spec satisfying the dependencies: Socket.IO-Client-Swift (~> 11.3.1), Socket.IO-Client-Swift (~> 11.2.1), Socket.IO-Client-Swift (~> 11.1.3), Socket.IO-Client-Swift (~> 10.3.1), Socket.IO-Client-Swift (~> 9.0.1).

You have either:

  • out-of-date source repos which you can update with pod repo update or with pod install --repo-update.
  • mistyped the name or version.
  • not added the source repo that hosts the Podspec to your Podfile.

Note: as of CocoaPods 1.0, pod repo update does not happen on pod install by default.
Unable to apply changes on device: F2A461E5-7335-4BB5-8659-5A16D9A2FC1B. Error is: Command pod failed with exit code 31 Error output:

I added some random ones aside from 11.1.3 in the code repo to try to get something to work.

..
"tns-android": {
"version": "3.4.1"
},
"tns-ios": {
"version": "3.4.1"
}
},
"dependencies": {
"nativescript-socketio": "^2.4.0",
"nativescript-theme-core": "~1.0.4",
"nativescript-ui-calendar": "^3.5.2",
"nativescript-ui-chart": "^3.5.0",
"nativescript-ui-dataform": "^3.5.2",
"nativescript-ui-gauge": "^3.5.0",
"nativescript-ui-listview": "^3.5.1",
"tns-core-modules": "^3.4.1"
},
"devDependencies": {
"babel-traverse": "6.4.5",
"babel-types": "6.4.5",
"babylon": "6.4.5",
"css-loader": "~0.28.7",
"lazy": "1.0.11",
"nativescript-dev-typescript": "^0.6.0",
"nativescript-worker-loader": "~0.8.1",
"raw-loader": "~0.5.1",
"resolve-url-loader": "~2.2.1",
"typescript": "^2.7.2"
}

TIA

emitWithItems is undefined

There seem to an issue the socket.ios.ts, I keep getting this error TypeError: this.socket.emitWithItems is not a function. (In 'this.socket.emitWithItems(event, payload)', 'this.socket.emitWithItems' is undefined).

After stepping through debugging the code it takes to the this.socket.emitWithItems(event, payload); inside the socket.ios.ts file which logs the above message.

I then added at the following to my Podfile but still have the same issue.

target "app" do
# Begin Podfile - /Users/tviel/Projects/pursUe/app/node_modules/nativescript-google-maps-sdk/platforms/ios/Podfile 
 pod 'GoogleMaps' 
 # End Podfile 
# Begin Podfile - /Users/tviel/Projects/pursUe/app/node_modules/nativescript-socketio/platforms/ios/Podfile 
 #pod 'Socket.IO-Client-Swift', :git => 'https://github.com/socketio/socket.io-client-swift.git'
 pod 'Socket.IO-Client-Swift', :git => 'https://github.com/socketio/socket.io-client-swift.git', :branch => 'swift2.3'

 # End Podfile 

end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '2.3'
    end
  end
end

how to connect to https

how to connect to https example : https:demo.com:5808

how to connect to https, I've tried if http work but https failed

Unicode problem

The package seems to be not parsing data as unicode. Is there any way to emit and receive unicode ?

Emit data doesn't enter in .on() event with nativescript core

Hello, I'm trying to use on() function, I send and receive data, but the .on([...]) doesn't work.

I set a breakpoint on line 11, but the debbuger never stops in that line.

My code:

var app = require("application");
var platform = require("platform");
var color = require("color");
var gestures = require("ui/gestures");
var labelModule = require("ui/label");
var SocketIO = require("nativescript-socketio").SocketIO;
var socketIO = new SocketIO("http://192.168.1.9:9000", []);
var dialogs = require("ui/dialogs");

socketIO.on("send command", function(data) {
  console.log(data); // This is line 11
});
socketIO.connect();

function dialogs2() {
  dialogs
    .action({
      message: "Set up drunki",
      cancelButtonText: "Cancel",
      actions: ["Send Calibrate request"]
    })
    .then(function(r) {
      console.log(socketIO.connected);
      if (socketIO.connected === false) return;
      socketIO.emit("send command", { message: "a" }); //Line 25
      setFullScreen();
    });
}
// Event handler for Page "loaded" event attached in main-page.xml
function pageLoaded(args) {
  if (app.android && platform.device.sdkVersion >= "21") setFullScreen();
}

function setFullScreen() {
  var View = android.view.View;
  var window = app.android.startActivity.getWindow();
  window.setStatusBarColor(0x000000);
  var decorView = window.getDecorView();
  decorView.setSystemUiVisibility(
    View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
    View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
    View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
    View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | // hide nav bar
    View.SYSTEM_UI_FLAG_FULLSCREEN | // hide status bar
      View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
  );
}

// Exports
exports.pageLoaded = pageLoaded;
exports.dialogs = dialogs2;

typo disconnect method

disconnect(): void {
this.socket.disconect();
}

should be
disconnect(): void {
this.socket.disconnect();
}

Android - emit object inside array

v2.3.1
sending an object inside an array will crash on Android. I did not yet test on IOS.
ie: .emit('oops', { 'this': [ { 'will': 'crash' } ] } );

Stacktrace

JS: EXCEPTION: Uncaught (in promise): Error: Cannot convert object to Ljava/lang/Object; at index 0
JS: ORIGINAL STACKTRACE:
JS: Error: Uncaught (in promise): Error: Cannot convert object to Ljava/lang/Object; at index 0
JS:     at resolvePromise (file:///data/data/org.nativescript.app/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:416:31)
JS:     at resolvePromise (file:///data/data/org.nativescript.app/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:401:17)
JS:     at file:///data/data/org.nativescript.app/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:449:17
JS:     at ZoneDelegate.invokeTask (file:///data/data/org.nativescript.app/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:223:37)
JS:     at Object.onInvokeTask (file:///data/data/org.nativescript.app/files/app/tns_modules/@angular/core/bundles/core.umd.js:3971:41)
JS:     at ZoneDelegate.invokeTask (file:///data/data/org.nativescript.app/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:222:42)
JS:     at Zone.runTask (file:///data/data/org.nativescript.app/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:123:47)
JS:     at drainMicroTaskQueue (file:///data/data/org.nativescript.app/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:355:35)
JS: Unhandled Promise rejection: Cannot convert object to Ljava/lang/Object; at index 0 ; Zone: angular ; Task: Promise.then ; Value: Error: Cannot convert object to Ljava/lang/Object; at index 0 Error: Cannot convert object to Ljava/lang/Object; at index 0
JS:     at file:///data/data/org.nativescript.app/files/app/tns_modules/nativescript-socketio/socketio.js:120:31
JS:     at Array.forEach (native)
JS:     at Function.SocketIO.serialize (file:///data/data/org.nativescript.app/files/app/tns_modules/nativescript-socketio/socketio.js:119:27)
JS:     at file:///data/data/org.nativescript.app/files/app/tns_modules/nativescript-socketio/socketio.js:127:45
JS:     at Array.forEach (native)
JS:     at SocketIO.serialize (file:///data/data/org.nativescript.app/files/app/tns_modules/nativescript-socketio/socketio.js:125:36)
JS:     at Array.map (native)
JS:     at SocketIO.emit (file:///data/data/org.nativescript.app/files/app/tns_modules/nativescript-socketio/socketio.js:66:27)
JS:     at WebSocketService.emit (file:///data/data/org.nativescript.app/files/app/provider/websocket.service.js:22:24)
JS: Error: Uncaught (in promise): Error: Cannot convert object to Ljava/lang/Object; at index 0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.