DeprecatedNetworkFunc.lua 1.1 KB

123456789101112131415161718192021222324252627
  1. if nil == cc.XMLHttpRequest then
  2. return
  3. end
  4. --tip
  5. local function deprecatedTip(old_name,new_name)
  6. print("\n********** \n"..old_name.." was deprecated please use ".. new_name .. " instead.\n**********")
  7. end
  8. --functions of WebSocket will be deprecated begin
  9. local targetPlatform = CCApplication:getInstance():getTargetPlatform()
  10. if (kTargetIphone == targetPlatform) or (kTargetIpad == targetPlatform) or (kTargetAndroid == targetPlatform) or (kTargetWindows == targetPlatform) then
  11. local WebSocketDeprecated = { }
  12. function WebSocketDeprecated.sendTextMsg(self, string)
  13. deprecatedTip("WebSocket:sendTextMsg","WebSocket:sendString")
  14. return self:sendString(string)
  15. end
  16. WebSocket.sendTextMsg = WebSocketDeprecated.sendTextMsg
  17. function WebSocketDeprecated.sendBinaryMsg(self, table,tablesize)
  18. deprecatedTip("WebSocket:sendBinaryMsg","WebSocket:sendString")
  19. string.char(unpack(table))
  20. return self:sendString(string.char(unpack(table)))
  21. end
  22. WebSocket.sendBinaryMsg = WebSocketDeprecated.sendBinaryMsg
  23. end
  24. --functions of WebSocket will be deprecated end