skynet.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef SKYNET_H
  2. #define SKYNET_H
  3. #include "skynet_malloc.h"
  4. #include <stddef.h>
  5. #include <stdint.h>
  6. #define PTYPE_TEXT 0
  7. #define PTYPE_RESPONSE 1
  8. #define PTYPE_MULTICAST 2
  9. #define PTYPE_CLIENT 3
  10. #define PTYPE_SYSTEM 4
  11. #define PTYPE_HARBOR 5
  12. #define PTYPE_SOCKET 6
  13. // read lualib/skynet.lua examples/simplemonitor.lua
  14. #define PTYPE_ERROR 7
  15. // read lualib/skynet.lua lualib/mqueue.lua lualib/snax.lua
  16. #define PTYPE_RESERVED_QUEUE 8
  17. #define PTYPE_RESERVED_DEBUG 9
  18. #define PTYPE_RESERVED_LUA 10
  19. #define PTYPE_RESERVED_SNAX 11
  20. #define PTYPE_TAG_DONTCOPY 0x10000
  21. #define PTYPE_TAG_ALLOCSESSION 0x20000
  22. struct skynet_context;
  23. void skynet_error(struct skynet_context * context, const char *msg, ...);
  24. const char * skynet_command(struct skynet_context * context, const char * cmd , const char * parm);
  25. uint32_t skynet_queryname(struct skynet_context * context, const char * name);
  26. int skynet_send(struct skynet_context * context, uint32_t source, uint32_t destination , int type, int session, void * msg, size_t sz);
  27. int skynet_sendname(struct skynet_context * context, uint32_t source, const char * destination , int type, int session, void * msg, size_t sz);
  28. int skynet_isremote(struct skynet_context *, uint32_t handle, int * harbor);
  29. typedef int (*skynet_cb)(struct skynet_context * context, void *ud, int type, int session, uint32_t source , const void * msg, size_t sz);
  30. void skynet_callback(struct skynet_context * context, void *ud, skynet_cb cb);
  31. uint32_t skynet_current_handle(void);
  32. uint64_t skynet_now(void);
  33. void skynet_debug_memory(const char *info); // for debug use, output current service memory to stderr
  34. #endif