Page 1 of 1

Export Kotlin Extension from Eclipse

Posted: 15 Jan 2019, 06:37
by balamost
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

Re: Export Kotlin Extension from Eclipse

Posted: 15 Jan 2019, 11:07
by Lapo
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

Re: Export Kotlin Extension from Eclipse

Posted: 17 Jan 2019, 07:47
by balamost
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.

Re: Export Kotlin Extension from Eclipse

Posted: 17 Jan 2019, 10:03
by Lapo
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

Re: Export Kotlin Extension from Eclipse

Posted: 19 Jan 2019, 04:11
by balamost
Hi,

Thanks, Labo a lot
I can resolve this by maven