Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Fuuj1n222 · Apr 17, 2013 at 04:08 AM · dllloginsmartfoxserversmartfoxserver2x

Problem with SmartFoxServer 2X - LoginAssistantComponent

Hi everyone,

I have recently moved from PhotonServer to SmartFoxServer 2X as the basic networking solution behind my game. One of the basic reassons is SmartFoxServer offers a login assistant component. This Login Assistant component is a helper class that assists in creating a database-driven login system, without the hassle of writing the database access code.

I was able to do all steps server side up to configuring the component in my client. I have the server running, the DB, I can connect to it, but I really don't know how to handle the last part, which is to "Instantiate the component in the init() method of my Extension".

Basically, I have no clue what it means... I'm pretty new to coding and unfortunately I have been using unityscript mostly. I can read C#, but when it gets to including external libraries I get a little confused.

You can access the Sfs2X LoginAssistantComponent documentation here:

I included the SmartFox2.dll in my Plugins folder, and have the following code working properly letting me connect and disconnect from my server.


 #pragma strict
 
 import System;
 import System.Collections.Generic;
 import Sfs2X;
 import Sfs2X.Core;
 import Sfs2X.Logging;
 
 var serverName = "insertmyserveriphere";
 var serverPort = 9933;
 var smartFox = new SmartFox(true);
 
 
 function OnGUI() {
     GUI.Box (Rect (20, 20, Screen.width - 40 , 25), "GAME NAME");
     GUI.Box (Rect (20, 50, Screen.width - 40 , Screen.height - 90), "Connection Screen");
     if (!smartFox.IsConnected) {
         if(GUI.Button(Rect(40, 165, Screen.width - 80, 20), "Connect")) {
             smartFox.Connect(serverName, serverPort);
         }
     }
     else if (smartFox.IsConnected) {
         if(GUI.Button(Rect(40, 165, Screen.width - 80, 20), "Disconnect")) {
             smartFox.Disconnect();
         }
     }    
 }


My problem occurs when I add the following code in order to declare a LoginAssistantComponent() variable. I get an Unknown identifier: 'LoginAssistantComponent'. error.


 function Test() {
     var lac = new LoginAssistantComponent();
 }


I know there is something else I have to do, but I have no clue what... Do I have to add another DLL in my project? do I have to "Include.Whatever" something else on top of my script? Do I have to wrap everything in something like


 public class ScriptName extends Something.MonoBehaviour{
 //code goes here
 }
 

By the way... Anyone can explain to me what these include lines up top are used for exactly? And why in some other times you have to use "public class ScriptName extends Photon.MonoBehaviour" like I had to when using PhotonNetwork?

Thanks for the help :)

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by NggingCrew · Jun 12, 2014 at 04:28 PM

 lac = new LoginAssistantComponent();

it's Server Code Extension for using Custom Login SmartFox (java).

in the unity you just call when you using LoginAssist Server Extension:

UNITY

     void Awake() {
             Application.runInBackground = true;
     
             if (Application.isWebPlayer || Application.isEditor) {
                 if (!Security.PrefetchSocketPolicy(serverName, serverPort, 500)) {
                     Debug.LogError("Security Exception. Policy file load failed!");
                 }
             }        
     
             if (SmartFoxConnection.IsInitialized)
             {
                 smartFox = SmartFoxConnection.Connection;
             } else {
                 Debug.Log("Whatever");
             }
             smartFox.AddEventListener(SFSEvent.CONNECTION, OnConnection);
             smartFox.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
             smartFox.AddEventListener(SFSEvent.LOGIN, OnLogin);
             smartFox.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
     
     
             smartFox.Connect(serverName, serverPort);
     }
     
     
     public void OnLoginError(BaseEvent evt)
     {
     Debug.Log("Error Login !!!");
     }
 
     public void OnLogin(BaseEvent evt) {
         bool success = true;
         if (evt.Params.Contains("success") && !(bool)evt.Params["success"]) {
             loginErrorMessage = (string)evt.Params["errorMessage"];
             Debug.Log("Login error: "+loginErrorMessage);
         } else {
             loginErrorMessage = "";
             UnregisterSFSSceneCallbacks();
             Application.LoadLevel("Whatever");
         }
     }

(Login from Database)

 smartFox.Send(new LoginRequest(username, password, zone));

(Guest)

 smartFox.Send(new LoginRequest(username,"", zone));



SERVER , USING NETBEAN

Don't forget add library sfs2x.jar and sfs2x-core.jar

 import com.smartfoxserver.v2.components.login.LoginAssistantComponent;
 import com.smartfoxserver.v2.components.login.LoginData;
 import com.smartfoxserver.v2.extensions.SFSExtension;
 
 public class YourServerName extends SFSExtension {
 
     public LoginAssistantComponent lac;
     
     @Override
     public void init(){
         lac = new LoginAssistantComponent(this);
         
         lac.getConfig().loginTable = "tableUser";
         lac.getConfig().userNameField = "Username";
         lac.getConfig().passwordField = "Password";
     }
 }




Then Build Extension and place (.jar) in /SmartFoxServer_2X/SFS2X/extensions/YourExtensionFolderName

Setting Zone Extension with your .jar extension

note: if you activate the custom login on the server SmartFox, then he will use the login username from database. But if not, then automatically defined as a guest.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

PlayerController and setting a variable 1 Answer

Smart fox+Mysql+unity=log in? 0 Answers

SmartFox2x SetVariable Request Error 0 Answers

SFS2X Client unusual disconnect cause Unity freeze 0 Answers

How to delete rooms in smartfox using C# 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges