Export Kotlin Extension from Eclipse

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

balamost
Posts: 9
Joined: 08 May 2017, 10:29

Export Kotlin Extension from Eclipse

Postby balamost » 15 Jan 2019, 06:37

I have been read this post: https://smartfoxserver.com/blog/kotlin- ... server-2x/
This post guild to create Kotlin Extension and export it by InteliJ.
But I wanna try with Eclipse
have Anybody know a guild about this?
please help me!
Thanks allot
User avatar
Lapo
Site Admin
Posts: 21643
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Export Kotlin Extension from Eclipse

Postby Lapo » 15 Jan 2019, 11:07

Hi,
(I moved your post in the correct section, since this is a request for SFS2X and you posted under SmartFoxServer PRO 1.x).

If you are already familiar with how Eclipse works you should have no problem setting up the project as project management should work the same in Java and Kotlin.

If you're not familiar with Eclipse then you can start with our guide here:
http://docs2x.smartfoxserver.com/Extens ... extensions

and apply the same concepts to a Kotlin project.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
balamost
Posts: 9
Joined: 08 May 2017, 10:29

Re: Export Kotlin Extension from Eclipse

Postby balamost » 17 Jan 2019, 07:47

Thanks, Labo!

I know how to export extension file in Java.

But when I do the same in Kotlin, I cannot add this extension to zone in server beccause I could not find out Main class
There are what I do:
1. Create Kotlin project and Write an extension class:

Code: Select all

import com.smartfoxserver.v2.core.ISFSEvent
import com.smartfoxserver.v2.core.SFSEventType
import com.smartfoxserver.v2.extensions.BaseServerEventHandler
import com.smartfoxserver.v2.extensions.SFSExtension
 
class EventHandler : BaseServerEventHandler()
{
    override fun handleServerEvent(event: ISFSEvent?)
    {
        trace("Event received >> " + event?.type)
    }
}
 
class KotlinEclipseExtension : SFSExtension()
{
    override  fun init()
    {
        trace("Kotlin Extension running in Zone: " + parentZone.toString())
 
        // Add server event handler
        addEventHandler(SFSEventType.SERVER_READY, EventHandler())
    }
 
    override fun destroy()
    {
        super.destroy()
 
        trace("Extension shutting down");
    }
}


2. Export to jar file which name: "KotlinEclipseExtension.jar" and put to extension folder
Image

3. Open the admin side and add a zone. But could not find extension name and Main class
Image


By another way, when Export I include the "kotlin_bin" folder
Image

Then I can find "extension name" and "Main class". I can Submit this new zone but it cannot start
Image

Reach this error when start server
Image

Sorry if this post too long.
User avatar
Lapo
Site Admin
Posts: 21643
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Export Kotlin Extension from Eclipse

Postby Lapo » 17 Jan 2019, 10:03

Hi,
none of the images are visible, instead of linking them externally just add them to the post.
At the botton of the post text area there's an "Attachments" tab. That's where you can add images.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
balamost
Posts: 9
Joined: 08 May 2017, 10:29

Re: Export Kotlin Extension from Eclipse

Postby balamost » 19 Jan 2019, 04:11

Hi,

Thanks, Labo a lot
I can resolve this by maven

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 23 guests