I’m using the Composer library so I have a network module.
This is the code where I called the module. And all I’m doing right now is trying to get the server to read the message:
local scene = {} local composer = require("composer") local widget = require("widget") local networking = require("src.modules.networking") local scene = composer.newScene() local screenWidth = display.viewableContentWidth local screenHeight = display.viewableContentHeight function login() networking:send("this is a login message, so dab on the left, and dab on the right") end function scene:create() local sceneGroup = self.view usernameBoxBackground = display.newRect(screenWidth/2, screenHeight/2 \* 1.5 - 49, 300, 39) usernameBox = native.newTextField(screenWidth/2, screenHeight/2 \* 1.5 - 49, 300, 39) passwordBoxBackground = display.newRect(screenWidth/2, screenHeight/2 \* 1.5, 300, 39) passwordBox = native.newTextField(screenWidth/2, screenHeight/2 \* 1.5, 300, 39) loginButton = widget.newButton({ width = 120, height = 48, label = "login", shape = "rect", fillColor = {default={1, 1, 1, 1}, over={1, 1, 1, 1}}, onEvent = login }) usernameBox.hasBackground = false passwordBox.hasBackground = false usernameBox.placeholder = "username" passwordBox.placeholder = "password" passwordBox.isSecure = true loginButton.x = screenWidth/2 loginButton.y = screenHeight/2 \* 1.5 + 54 sceneGroup:insert(usernameBoxBackground) sceneGroup:insert(passwordBoxBackground) sceneGroup:insert(loginButton) sceneGroup:insert(usernameBox) sceneGroup:insert(passwordBox) end function scene:show(event) if event.phase == "did" then composer.setVariable("lastScene", composer.getVariable("currentScene")) composer.setVariable("currentScene", "src.panels.login-signup.login") end end function scene:hide() local sceneGroup = self.view end scene:addEventListener("create", scene) scene:addEventListener("show", scene) scene:addEventListener("hide", scene) return scene