Giter Site home page Giter Site logo

node-kcp's People

Contributors

leenjewel 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  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  avatar  avatar  avatar  avatar  avatar  avatar

node-kcp's Issues

Cannot use in Electron

When trying to require the npm lib in an Electron app, you get the following error

Uncaught (in promise) Error: Loading non-context-aware native module in renderer: '\\?\C:\Users\alona\dev\MyProj\app\node_modules\node-kcp-token\build\Release\kcp.node'. See https://github.com/electron/electron/issues/18397.
    at process.func [as dlopen] (node:electron/js2c/asar_bundle:2:1822)
    at Module._extensions..node (node:internal/modules/cjs/loader:1226:18)
    at Object.func [as .node] (node:electron/js2c/asar_bundle:2:1822)
    at Module.load (node:internal/modules/cjs/loader:1011:32)
    at Module._load (node:internal/modules/cjs/loader:846:12)
    at f._load (node:electron/js2c/asar_bundle:2:13330)
    at o._load (node:electron/js2c/renderer_init:2:3109)
    at Module.require (node:internal/modules/cjs/loader:1035:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (C:\Users\alona\dev\MyProj\app\node_modules\node-kcp-token\index.js:1:173)

It appears that the following fork fixed it, however fails to compile on win 32 bit, upon npm install
https://github.com/bruce48x/node-kcp

Invalid 'main' field

DeprecationWarning: Invalid 'main' field in 'package.json' of 'node-kcp.node'. Please either fix that or report it to the module author

bug of Recv

NAN_METHOD(KCPObject::Recv)
{
KCPObject* thiz = ObjectWrap::Unwrap(info.Holder());
int bufsize = 0;
char* buf = NULL;
int buflen = 0;
char* data = NULL;
int len = 0;
char* tmp = NULL;
int tmplen = 0;
while(1) {
tmplen = len;//chg one(修改1)
bufsize = ikcp_peeksize(thiz->kcp);
if (bufsize <= 0) {
break;
}
int align = bufsize % 4;
if (align) {
bufsize += 4 - align;
}
buf = (char*)malloc(bufsize);
buflen = ikcp_recv(thiz->kcp, buf, bufsize);
if (buflen <= 0) {
free(buf);
break;
}
len += buflen;
tmp = data;
data = (char*)malloc(len);
if (NULL != tmp) {
memcpy(data, tmp, tmplen);
free(tmp);
}
memcpy(data+tmplen, buf, buflen); //chg 2, copy need offset(修改2,开始没有偏移量,所以每次都拷贝在offset 0)
free(buf);
}
if (len > 0) {
info.GetReturnValue().Set(
Nan::CopyBuffer((const char*)data, len).ToLocalChecked()
);
}
free(data);
}

node12安装失败。V8不匹配

make: Entering directory `/data1/game-server/node_modules/node-kcp/build'
CC(target) Release/obj.target/kcp/src/kcp/ikcp.o
../src/kcp/ikcp.c: In function ‘ikcp_send’:
../src/kcp/ikcp.c:508:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (count >= IKCP_WND_RCV) return -2;
^
CXX(target) Release/obj.target/kcp/src/kcpobject.o
../src/kcpobject.cc: In static member function ‘static int node_kcp::KCPObject::kcp_output(const char*, int, ikcpcb*, void*)’:
../src/kcpobject.cc:67:37: warning: ‘v8::Localv8::Value Nan::Callback::Call(int, v8::Localv8::Value) const’ is deprecated (declared at ../../nan/nan.h:1740) [-Wdeprecated-declarations]
callback.Call(argc, argv);
^
../src/kcpobject.cc:76:37: warning: ‘v8::Localv8::Value Nan::Callback::Call(int, v8::Localv8::Value) const’ is deprecated (declared at ../../nan/nan.h:1740) [-Wdeprecated-declarations]
callback.Call(argc, argv);
^
../src/kcpobject.cc: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE node_kcp::KCPObject::Input(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/kcpobject.cc:223:36: error: no matching function for call to ‘v8::String::Value::Value(v8::Localv8::Value&)’
String::Value data(arg0);

node -v v12.14.0
node-gyp -v v5.0.5
npm-v 6.13.4
gcc 4.8.5

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.