SlideShare a Scribd company logo
1 of 18
網路遊戲設計 Web Game Design 授課教師 江素貞
Chapter 6 User Variable and Room Variable User Variables
User Variable Types In multiplayer games, chats, and other types of interactive applications, it is often useful to attach information to a user that stays with that user at all times.  ElectroServer supports that concept through User Variables, User Plugin Variables, User Extension Variables, and User Server Variables.
User Variables A User Variable is a name/value pair stored on the server and scoped to a user. A user can have many User Variables. User Variables of a user are seen by other users in the same room. Users in that room can receive User Variable Update events when User Variables are changed. (MessageType.UserListUpdateEvent) A user can create, update, or delete his own User Variables.  Server extensions can create, update, or delete User Variables on any user.
EsObject The value of a User Variable is an EsObject.  EsObject is an object that supports a large number of data types. It allows the server and client, or clients and other clients, to exchange simple or complex object structures that retain data types. In addition, EsObjects are used in many places when dealing with extensions and values for room variables, user variables, and user server variables.
Creating an EsObject To use an EsObject, you must first create a new instance and then set values on it using the provided methods. import com.electrotank.electroserver4.esobject.EsObject; varesob:EsObject = new EsObject(); esob.setString("FirstName", "Jobe"); esob.setInteger("Age",32); esob.setBoolean("isCool", false); esob.setFloatArray("FavoriteFloats", [3.141, 2.718]);
Update User Variable Simple Example: varuserData:EsObject = new EsObject(); userData.setString("realName", loginScreen.name_txt.text); userData.setInteger("score", 0); varuv:UpdateUserVariableRequest = new UpdateUserVariableRequest(); uv.setValue( userData ); uv.setName( "data" ); es.send(uv);
Obtain User Variable varuser:User=es.getUserManager().getUserByName(“xxx”) //user 必須視狀況取得 var d:EsObject = user.getUserVariable("data").getValue(); FlashConnect.trace(d.getString("realName"));
Chapter 6 User Variable and Room Variable Room Variables
Room Variables Room Variables are name/value pairs stored on the server and scoped to a room.  These variables are seen by users in that room and are accessible by server extensions.  Room variables can be created during the room creation process, by users in the room, or by server extensions. The value of a room variable is an EsObject.
Why Are Room Variables Useful? Room Variables provide a convenient way for developers to accomplish simple things easily. For instance, Room Variables can be set in a room to specify the background music to play, the chat skin to use, etc.
CreateRoomVariableRequest This class allows you to create a room variable. A room variable is a variable scoped to a room that you are in and stored on the server. All users in your room receive these variables on entering the room, and receive create, update, and delete events on variables after they are already in the room.
Creating a Room Variable When a client creates a room variable the following are specified: Room Id (integer) – The id of the room in which to create the Room Variable. Zone Id (integer) – The id of the zone that owns the room. Name (string) – The name of the Room Variable. Value (EsObject) – The EsObject value of the Room Variable. Locked (Boolean) – If true then the variable cannot be modified until it is unlocked. If false then the variable value can be modified. Persistent (Boolean) – If true then when the user that creates the Room Variable leaves the room the variable remains. If false then when the user that created the Room Variable leaves the room the variable is removed
Creating a Room Variable vareob:EsObject = new EsObject();  eob.setString("LoopName", "Happy.mp3");  eob.setInteger("Volume", 80);  varcrr:CreateRoomVariableRequest = new CreateRoomVariableRequest();  crr.setName("MusicInfo");  crr.setValue(eob);  crr.setRoomId(myRoom.getRoomId()); crr.setZoneId(myRoom.getZone().getZoneId());  //crr.setLocked(false);  //crr.setPersistent(false);  es.send(crr);
Event Listen es.addEventListener(MessageType.RoomVariableUpdateEvent, "onRoomVariableUpdateEvent", this); function onRoomVariableUpdateEvent(e:RoomVariableUpdateEvent):void { varvarName:String = e.getName();  varroom:Room = es.getZoneManager().getZoneById(e.getZoneId()).getRoomById(e.getRoomId());  	switch (e.getUpdateAction()) {  		case RoomVariableUpdateEvent.VariableCreated:  		case RoomVariableUpdateEvent.VariableUpdated:  		case RoomVariableUpdateEvent.VariableDeleted:  		default:  	} }
UpdateRoomVariableRequest This class allows you to update an existing room variable. You identify a room variable by room id, zone id, and name. You can update a variables value and locked property. The value of the variable is an EsObject.
Updating a Room Variable A Room Variable can be updated by changing its locked status or by changing its value.
Update Room Variable vareob:EsObject = new EsObject();  eob.setString("LoopName", "Sad.mp3");  eob.setInteger("Volume", 50);  varurvr:UpdateRoomVariableRequest  = new UpdateRoomVariableRequest();  urvr.setName("MusicInfo");  urvr.setValue(eob);  urvr.setRoomId(myRoom.getRoomId()); urvr.setZoneId(myRoom.getZone().getZoneId());  //urvr.setLocked(true);  es.send(urvr);

More Related Content

What's hot

JQuery plugin development fundamentals
JQuery plugin development fundamentalsJQuery plugin development fundamentals
JQuery plugin development fundamentalsBastian Feder
 
[Swift] Memento
[Swift] Memento[Swift] Memento
[Swift] MementoBill Kim
 
Javascript Experiment
Javascript ExperimentJavascript Experiment
Javascript Experimentwgamboa
 
Jquery Plugin
Jquery PluginJquery Plugin
Jquery PluginRavi Mone
 
Functionality Focused Code Organization
Functionality Focused Code OrganizationFunctionality Focused Code Organization
Functionality Focused Code OrganizationRebecca Murphey
 
Jquery plugin development
Jquery plugin developmentJquery plugin development
Jquery plugin developmentMd. Ziaul Haq
 
Beyond the DOM: Sane Structure for JS Apps
Beyond the DOM: Sane Structure for JS AppsBeyond the DOM: Sane Structure for JS Apps
Beyond the DOM: Sane Structure for JS AppsRebecca Murphey
 
Mulberry: A Mobile App Development Toolkit
Mulberry: A Mobile App Development ToolkitMulberry: A Mobile App Development Toolkit
Mulberry: A Mobile App Development ToolkitRebecca Murphey
 
Cleaner, Leaner, Meaner: Refactoring your jQuery
Cleaner, Leaner, Meaner: Refactoring your jQueryCleaner, Leaner, Meaner: Refactoring your jQuery
Cleaner, Leaner, Meaner: Refactoring your jQueryRebecca Murphey
 
jQuery Fundamentals
jQuery FundamentalsjQuery Fundamentals
jQuery FundamentalsGil Fink
 
Building Large jQuery Applications
Building Large jQuery ApplicationsBuilding Large jQuery Applications
Building Large jQuery ApplicationsRebecca Murphey
 
iOS Talks 1 - CodeCamp Osijek - Swift u praksi
iOS Talks 1 - CodeCamp Osijek - Swift u praksiiOS Talks 1 - CodeCamp Osijek - Swift u praksi
iOS Talks 1 - CodeCamp Osijek - Swift u praksiMarin Benčević
 
A New Baseline for Front-End Devs
A New Baseline for Front-End DevsA New Baseline for Front-End Devs
A New Baseline for Front-End DevsRebecca Murphey
 

What's hot (20)

JQuery plugin development fundamentals
JQuery plugin development fundamentalsJQuery plugin development fundamentals
JQuery plugin development fundamentals
 
Web 6 | JavaScript DOM
Web 6 | JavaScript DOMWeb 6 | JavaScript DOM
Web 6 | JavaScript DOM
 
[Swift] Memento
[Swift] Memento[Swift] Memento
[Swift] Memento
 
Javascript Experiment
Javascript ExperimentJavascript Experiment
Javascript Experiment
 
Jquery Plugin
Jquery PluginJquery Plugin
Jquery Plugin
 
Functionality Focused Code Organization
Functionality Focused Code OrganizationFunctionality Focused Code Organization
Functionality Focused Code Organization
 
Jquery plugin development
Jquery plugin developmentJquery plugin development
Jquery plugin development
 
Beyond the DOM: Sane Structure for JS Apps
Beyond the DOM: Sane Structure for JS AppsBeyond the DOM: Sane Structure for JS Apps
Beyond the DOM: Sane Structure for JS Apps
 
JavaScript patterns
JavaScript patternsJavaScript patterns
JavaScript patterns
 
Mulberry: A Mobile App Development Toolkit
Mulberry: A Mobile App Development ToolkitMulberry: A Mobile App Development Toolkit
Mulberry: A Mobile App Development Toolkit
 
Cleaner, Leaner, Meaner: Refactoring your jQuery
Cleaner, Leaner, Meaner: Refactoring your jQueryCleaner, Leaner, Meaner: Refactoring your jQuery
Cleaner, Leaner, Meaner: Refactoring your jQuery
 
BVJS
BVJSBVJS
BVJS
 
jQuery Fundamentals
jQuery FundamentalsjQuery Fundamentals
jQuery Fundamentals
 
jQuery
jQueryjQuery
jQuery
 
J Query
J QueryJ Query
J Query
 
Building Large jQuery Applications
Building Large jQuery ApplicationsBuilding Large jQuery Applications
Building Large jQuery Applications
 
iOS Talks 1 - CodeCamp Osijek - Swift u praksi
iOS Talks 1 - CodeCamp Osijek - Swift u praksiiOS Talks 1 - CodeCamp Osijek - Swift u praksi
iOS Talks 1 - CodeCamp Osijek - Swift u praksi
 
Web 5 | JavaScript Events
Web 5 | JavaScript EventsWeb 5 | JavaScript Events
Web 5 | JavaScript Events
 
A New Baseline for Front-End Devs
A New Baseline for Front-End DevsA New Baseline for Front-End Devs
A New Baseline for Front-End Devs
 
Dojo Confessions
Dojo ConfessionsDojo Confessions
Dojo Confessions
 

Viewers also liked

Login and private message
Login and private messageLogin and private message
Login and private messagegueste832a8e
 
Final digital space & strategy ppt april 2010
Final digital space & strategy ppt april 2010Final digital space & strategy ppt april 2010
Final digital space & strategy ppt april 2010Jimit Shah
 
Business Learning Strategy
Business Learning StrategyBusiness Learning Strategy
Business Learning StrategyNick DeNardo
 
Revelation (Part One B)
Revelation (Part One B)Revelation (Part One B)
Revelation (Part One B)Chrissy Philp
 
The perfect natural intelligence system
The perfect natural intelligence systemThe perfect natural intelligence system
The perfect natural intelligence systemChrissy Philp
 
Oppositions on the Anima Mundi
Oppositions on the Anima MundiOppositions on the Anima Mundi
Oppositions on the Anima MundiChrissy Philp
 
Anima Mundi Presentation
Anima Mundi PresentationAnima Mundi Presentation
Anima Mundi PresentationChrissy Philp
 
Electromagnetism, gravity and consciousness, is there a connection?
Electromagnetism, gravity and consciousness, is there a connection?Electromagnetism, gravity and consciousness, is there a connection?
Electromagnetism, gravity and consciousness, is there a connection?Chrissy Philp
 
How to make a mess of your feathers
How to make a mess of your feathersHow to make a mess of your feathers
How to make a mess of your feathersChrissy Philp
 
Todos los trabajos
Todos los trabajos Todos los trabajos
Todos los trabajos Juliiita
 
I Ching and Anima Mundi
I Ching and Anima MundiI Ching and Anima Mundi
I Ching and Anima MundiChrissy Philp
 

Viewers also liked (15)

Social justice
Social justiceSocial justice
Social justice
 
Les 1 ppt
Les 1 pptLes 1 ppt
Les 1 ppt
 
Les 3 ppt
Les 3 pptLes 3 ppt
Les 3 ppt
 
Login and private message
Login and private messageLogin and private message
Login and private message
 
Final digital space & strategy ppt april 2010
Final digital space & strategy ppt april 2010Final digital space & strategy ppt april 2010
Final digital space & strategy ppt april 2010
 
Business Learning Strategy
Business Learning StrategyBusiness Learning Strategy
Business Learning Strategy
 
Revelation (Part One B)
Revelation (Part One B)Revelation (Part One B)
Revelation (Part One B)
 
Tree of life
Tree of lifeTree of life
Tree of life
 
The perfect natural intelligence system
The perfect natural intelligence systemThe perfect natural intelligence system
The perfect natural intelligence system
 
Oppositions on the Anima Mundi
Oppositions on the Anima MundiOppositions on the Anima Mundi
Oppositions on the Anima Mundi
 
Anima Mundi Presentation
Anima Mundi PresentationAnima Mundi Presentation
Anima Mundi Presentation
 
Electromagnetism, gravity and consciousness, is there a connection?
Electromagnetism, gravity and consciousness, is there a connection?Electromagnetism, gravity and consciousness, is there a connection?
Electromagnetism, gravity and consciousness, is there a connection?
 
How to make a mess of your feathers
How to make a mess of your feathersHow to make a mess of your feathers
How to make a mess of your feathers
 
Todos los trabajos
Todos los trabajos Todos los trabajos
Todos los trabajos
 
I Ching and Anima Mundi
I Ching and Anima MundiI Ching and Anima Mundi
I Ching and Anima Mundi
 

Similar to User variable and room variable

Local data storage for mobile apps
Local data storage for mobile appsLocal data storage for mobile apps
Local data storage for mobile appsIvano Malavolta
 
Eureka - elegant iOs form builder in swift (johnp - mingle)
Eureka - elegant iOs form builder in swift (johnp - mingle)Eureka - elegant iOs form builder in swift (johnp - mingle)
Eureka - elegant iOs form builder in swift (johnp - mingle)John Pham
 
SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdf
SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdfSummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdf
SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdfARORACOCKERY2111
 
How to test complex SaaS applications - The family july 2014
How to test complex SaaS applications - The family july 2014How to test complex SaaS applications - The family july 2014
How to test complex SaaS applications - The family july 2014Guillaume POTIER
 
Implementation of EAV pattern for ActiveRecord models
Implementation of EAV pattern for ActiveRecord modelsImplementation of EAV pattern for ActiveRecord models
Implementation of EAV pattern for ActiveRecord modelsKostyantyn Stepanyuk
 
Java SE 8 for Java EE developers
Java SE 8 for Java EE developersJava SE 8 for Java EE developers
Java SE 8 for Java EE developersJosé Paumard
 
Creating an Uber Clone - Part XXXX - Transcript.pdf
Creating an Uber Clone - Part XXXX - Transcript.pdfCreating an Uber Clone - Part XXXX - Transcript.pdf
Creating an Uber Clone - Part XXXX - Transcript.pdfShaiAlmog1
 
Backbone js
Backbone jsBackbone js
Backbone jsrstankov
 
Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]Sven Efftinge
 
Creating a Whatsapp Clone - Part XIV - Transcript.pdf
Creating a Whatsapp Clone - Part XIV - Transcript.pdfCreating a Whatsapp Clone - Part XIV - Transcript.pdf
Creating a Whatsapp Clone - Part XIV - Transcript.pdfShaiAlmog1
 
Svcc Building Rich Applications with Groovy's SwingBuilder
Svcc Building Rich Applications with Groovy's SwingBuilderSvcc Building Rich Applications with Groovy's SwingBuilder
Svcc Building Rich Applications with Groovy's SwingBuilderAndres Almiray
 
Local storage in Web apps
Local storage in Web appsLocal storage in Web apps
Local storage in Web appsIvano Malavolta
 
1.what is the difference between a instance variable and an local va.pdf
1.what is the difference between a instance variable and an local va.pdf1.what is the difference between a instance variable and an local va.pdf
1.what is the difference between a instance variable and an local va.pdfarchgeetsenterprises
 
Sql server ___________session_18(stored procedures)
Sql server  ___________session_18(stored procedures)Sql server  ___________session_18(stored procedures)
Sql server ___________session_18(stored procedures)Ehtisham Ali
 
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdf
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdfNeed help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdf
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdffastechsrv
 
Creative Web 2 - JavaScript
Creative Web 2 - JavaScript Creative Web 2 - JavaScript
Creative Web 2 - JavaScript Lukas Oppermann
 

Similar to User variable and room variable (20)

Local data storage for mobile apps
Local data storage for mobile appsLocal data storage for mobile apps
Local data storage for mobile apps
 
Eureka - elegant iOs form builder in swift (johnp - mingle)
Eureka - elegant iOs form builder in swift (johnp - mingle)Eureka - elegant iOs form builder in swift (johnp - mingle)
Eureka - elegant iOs form builder in swift (johnp - mingle)
 
SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdf
SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdfSummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdf
SummaryHW6 Account ManagementIn HW4, you kept track of multiple.pdf
 
How to test complex SaaS applications - The family july 2014
How to test complex SaaS applications - The family july 2014How to test complex SaaS applications - The family july 2014
How to test complex SaaS applications - The family july 2014
 
Implementation of EAV pattern for ActiveRecord models
Implementation of EAV pattern for ActiveRecord modelsImplementation of EAV pattern for ActiveRecord models
Implementation of EAV pattern for ActiveRecord models
 
Ruby Classes
Ruby ClassesRuby Classes
Ruby Classes
 
Java SE 8 for Java EE developers
Java SE 8 for Java EE developersJava SE 8 for Java EE developers
Java SE 8 for Java EE developers
 
Creating an Uber Clone - Part XXXX - Transcript.pdf
Creating an Uber Clone - Part XXXX - Transcript.pdfCreating an Uber Clone - Part XXXX - Transcript.pdf
Creating an Uber Clone - Part XXXX - Transcript.pdf
 
Ejb3 Dan Hinojosa
Ejb3 Dan HinojosaEjb3 Dan Hinojosa
Ejb3 Dan Hinojosa
 
Os Leonard
Os LeonardOs Leonard
Os Leonard
 
Backbone js
Backbone jsBackbone js
Backbone js
 
Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]
 
Creating a Whatsapp Clone - Part XIV - Transcript.pdf
Creating a Whatsapp Clone - Part XIV - Transcript.pdfCreating a Whatsapp Clone - Part XIV - Transcript.pdf
Creating a Whatsapp Clone - Part XIV - Transcript.pdf
 
Svcc Building Rich Applications with Groovy's SwingBuilder
Svcc Building Rich Applications with Groovy's SwingBuilderSvcc Building Rich Applications with Groovy's SwingBuilder
Svcc Building Rich Applications with Groovy's SwingBuilder
 
Local storage in Web apps
Local storage in Web appsLocal storage in Web apps
Local storage in Web apps
 
1.what is the difference between a instance variable and an local va.pdf
1.what is the difference between a instance variable and an local va.pdf1.what is the difference between a instance variable and an local va.pdf
1.what is the difference between a instance variable and an local va.pdf
 
Sql server ___________session_18(stored procedures)
Sql server  ___________session_18(stored procedures)Sql server  ___________session_18(stored procedures)
Sql server ___________session_18(stored procedures)
 
Java Script ppt
Java Script pptJava Script ppt
Java Script ppt
 
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdf
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdfNeed help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdf
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdf
 
Creative Web 2 - JavaScript
Creative Web 2 - JavaScript Creative Web 2 - JavaScript
Creative Web 2 - JavaScript
 

Recently uploaded

Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 

Recently uploaded (20)

Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 

User variable and room variable

  • 1. 網路遊戲設計 Web Game Design 授課教師 江素貞
  • 2. Chapter 6 User Variable and Room Variable User Variables
  • 3. User Variable Types In multiplayer games, chats, and other types of interactive applications, it is often useful to attach information to a user that stays with that user at all times. ElectroServer supports that concept through User Variables, User Plugin Variables, User Extension Variables, and User Server Variables.
  • 4. User Variables A User Variable is a name/value pair stored on the server and scoped to a user. A user can have many User Variables. User Variables of a user are seen by other users in the same room. Users in that room can receive User Variable Update events when User Variables are changed. (MessageType.UserListUpdateEvent) A user can create, update, or delete his own User Variables. Server extensions can create, update, or delete User Variables on any user.
  • 5. EsObject The value of a User Variable is an EsObject. EsObject is an object that supports a large number of data types. It allows the server and client, or clients and other clients, to exchange simple or complex object structures that retain data types. In addition, EsObjects are used in many places when dealing with extensions and values for room variables, user variables, and user server variables.
  • 6. Creating an EsObject To use an EsObject, you must first create a new instance and then set values on it using the provided methods. import com.electrotank.electroserver4.esobject.EsObject; varesob:EsObject = new EsObject(); esob.setString("FirstName", "Jobe"); esob.setInteger("Age",32); esob.setBoolean("isCool", false); esob.setFloatArray("FavoriteFloats", [3.141, 2.718]);
  • 7. Update User Variable Simple Example: varuserData:EsObject = new EsObject(); userData.setString("realName", loginScreen.name_txt.text); userData.setInteger("score", 0); varuv:UpdateUserVariableRequest = new UpdateUserVariableRequest(); uv.setValue( userData ); uv.setName( "data" ); es.send(uv);
  • 8. Obtain User Variable varuser:User=es.getUserManager().getUserByName(“xxx”) //user 必須視狀況取得 var d:EsObject = user.getUserVariable("data").getValue(); FlashConnect.trace(d.getString("realName"));
  • 9. Chapter 6 User Variable and Room Variable Room Variables
  • 10. Room Variables Room Variables are name/value pairs stored on the server and scoped to a room. These variables are seen by users in that room and are accessible by server extensions. Room variables can be created during the room creation process, by users in the room, or by server extensions. The value of a room variable is an EsObject.
  • 11. Why Are Room Variables Useful? Room Variables provide a convenient way for developers to accomplish simple things easily. For instance, Room Variables can be set in a room to specify the background music to play, the chat skin to use, etc.
  • 12. CreateRoomVariableRequest This class allows you to create a room variable. A room variable is a variable scoped to a room that you are in and stored on the server. All users in your room receive these variables on entering the room, and receive create, update, and delete events on variables after they are already in the room.
  • 13. Creating a Room Variable When a client creates a room variable the following are specified: Room Id (integer) – The id of the room in which to create the Room Variable. Zone Id (integer) – The id of the zone that owns the room. Name (string) – The name of the Room Variable. Value (EsObject) – The EsObject value of the Room Variable. Locked (Boolean) – If true then the variable cannot be modified until it is unlocked. If false then the variable value can be modified. Persistent (Boolean) – If true then when the user that creates the Room Variable leaves the room the variable remains. If false then when the user that created the Room Variable leaves the room the variable is removed
  • 14. Creating a Room Variable vareob:EsObject = new EsObject(); eob.setString("LoopName", "Happy.mp3"); eob.setInteger("Volume", 80); varcrr:CreateRoomVariableRequest = new CreateRoomVariableRequest(); crr.setName("MusicInfo"); crr.setValue(eob); crr.setRoomId(myRoom.getRoomId()); crr.setZoneId(myRoom.getZone().getZoneId()); //crr.setLocked(false); //crr.setPersistent(false); es.send(crr);
  • 15. Event Listen es.addEventListener(MessageType.RoomVariableUpdateEvent, "onRoomVariableUpdateEvent", this); function onRoomVariableUpdateEvent(e:RoomVariableUpdateEvent):void { varvarName:String = e.getName(); varroom:Room = es.getZoneManager().getZoneById(e.getZoneId()).getRoomById(e.getRoomId()); switch (e.getUpdateAction()) { case RoomVariableUpdateEvent.VariableCreated: case RoomVariableUpdateEvent.VariableUpdated: case RoomVariableUpdateEvent.VariableDeleted: default: } }
  • 16. UpdateRoomVariableRequest This class allows you to update an existing room variable. You identify a room variable by room id, zone id, and name. You can update a variables value and locked property. The value of the variable is an EsObject.
  • 17. Updating a Room Variable A Room Variable can be updated by changing its locked status or by changing its value.
  • 18. Update Room Variable vareob:EsObject = new EsObject(); eob.setString("LoopName", "Sad.mp3"); eob.setInteger("Volume", 50); varurvr:UpdateRoomVariableRequest = new UpdateRoomVariableRequest(); urvr.setName("MusicInfo"); urvr.setValue(eob); urvr.setRoomId(myRoom.getRoomId()); urvr.setZoneId(myRoom.getZone().getZoneId()); //urvr.setLocked(true); es.send(urvr);