Search code examples
actionscript-3classflashdevelopimplementsappwarp

AppWarp Implementation


I am trying to implement AppWarp into a game I am making. I followed a tutorial exactly as it was written but I am getting about a dozen errors at "NetworkPeer implements". Some of the errors are:

Error: Interface method onConnectDone in namespace com.shephertz.appwarp.listener:ConnectionRequestListener not implemented by class NetworkPeer.

Error: Interface method onDisConnectDone in namespace com.shephertz.appwarp.listener:ConnectionRequestListener not implemented by class NetworkPeer.

And so on...

Any help is greatly appreciated!

public class NetworkPeer implements ConnectionRequestListener, RoomRequestListener, NotificationListener
        {
            public var roomID:String = "Room";
            private var apiKey:String = "API_ID"
            private var secretKey:String = "Secret_Key";
            private var localUsername = Math.random().toString();

            public function NetworkPeer()
            {
                WarpClient.initialize(apiKey, secretKey);
                WarpClient.getInstance().setConnectionRequestListener(null);
                WarpClient.getInstance().setRoomRequestListener(null);
                WarpClient.getInstance().setNotificationListener(null);
            }

            private function connect_click(e:MouseEvent):void
            {
                if (WarpClient.getInstance().getConnectionState() == ConnectionState.disconnected)
                {
                    WarpClient.getInstance().connect(localUsername);
                    Main.connectbtn.text = "Connecting..";
                }
            }

        }

Solution

  • You are getting this error because, you have implemented listeners like ConnectionRequestListener to NetWorkPeer class but not defined corresponding callback methods like onConnectDone in NetworkPeer.

    The AppWarp APIs are developed to be used asynchronously, and in order to receive responses and updates from the AppWarp Server, you need to add corresponding request listeners to the WarpClient instance.

    In the code snippets, you are adding null as listener which is not needed. You only need to add the listeners and its callback methods which you want to receive in your game.

    For example, if you call connect API then you need to add ConnectionRequestListener and define onConnectDone callback method to get the response from the AppWarp Server.

    You can have a look at this sample to know more about the integration of AppWarp into your ActionScript project.

    You can also go through the AppWarp Getting Started page for Action Script to know more about the necessary steps which need to be done.

    If you face any further problems , you can always write on our Forum or on [email protected].