Matthias247 / jawampa

Web Application Messaging Protocol (WAMP v2) support for Java
Apache License 2.0
148 stars 56 forks source link

Added register flag disclose_caller option #87

Closed zhaojin0 closed 8 years ago

zhaojin0 commented 8 years ago

Hi.

I added procedure register flags feature, and impl disclose_caller. Jawampa very important in my projects. I like it.

the20login commented 8 years ago

I see implementation for WampClient and client session, but no implementation for WampRouter. Are you planning to provide it?

Also, could you provide some examples for this feature? From my perspective, it's not very useful, you could achive same behaviour by sending client id manually.

zhaojin0 commented 8 years ago

I use crossbar router and jawampa client for a multi-tenancy saas app, it's need some advanced features, like session meta api

Caller call a procedure, and callee want to known who call me.

example:

jawampa client register a procedure with disclose_caller.

when js or other client call procedure, crossbar router send a Invocation message to callee, like this:

[68,456,8621176679032285,{"caller":8244033548475732,"caller_authid":"agent2@unicall.cc","caller_authrole":"agents"}]

Invocation message contains caller session id, callee call procedure wamp.session.get to get session information.

crossbar will return session information, like this (after some modified):

[50, 92, {}, [{
  "authprovider": "dynamic",
  "authid": "agent2@unicall.cc",
  "authrole": "agents",
  "authmethod": "ticket",
  "session": 8244033548475732,
  "transport": {
    "cbtid": null,
    "protocol": "wamp.2.json",
    "http_headers_received": {
      "origin": "https://tenant.yunkefu.com",
      "upgrade": "websocket",
      "accept-language": "zh-CN,zh;q=0.8",
      "accept-encoding": "gzip, deflate, sdch",
      "x-forwarded-for": "192.168.11.191",
      "sec-websocket-version": "13",
      "sec-websocket-protocol": "wamp.2.json",
      "host": "tenant.yunkefu.com",
      "sec-websocket-key": "+pf13UEStkaaAZKzb4DQ5g==",
      "user-agent": "Mozilla/5.0 (X11; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0",
      "connection": "Upgrade",
      "x-forwarded-proto": "https",
      "cookie": "JSESSIONID=JSESSION_ID",
      "pragma": "no-cache",
      "cache-control": "no-cache",
      "sec-websocket-extensions": "permessage-deflate; client_max_window_bits"
    },
    "peer": "tcp4:10.0.0.10:50424",
    "http_headers_sent": {},
    "type": "websocket"
  }
}]]

Callee get headers like Host / Cookie / Accept-Language etc. from headers.

the20login commented 8 years ago

Thanks for detailed reply.

Unfortunately, @Matthias247 doesn't actively support Jawampa, so approving commit could take considerable time.

Matthias247 commented 8 years ago

Can you implement registerProcedure(final String topic) in terms of calling registerProcedure(final String topic, final RegisterFlags... flags)? No need to duplicate code inside the methods.

zhaojin0 commented 8 years ago

Removed duplicate code and added method registerProcedure(final String topic, final EnumSet<RegisterFlags> flags)

Matthias247 commented 8 years ago

Sorry for the delay. Looks good and is merged now.