Package org.zkoss.zats.mimic.impl
Class EmulatorClient
- java.lang.Object
-
- org.zkoss.zats.mimic.impl.EmulatorClient
-
- All Implemented Interfaces:
Client,ClientCtrl
public class EmulatorClient extends Object implements Client, ClientCtrl
The default server emulator client implementation.- Author:
- pao
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.zkoss.zats.mimic.impl.ClientCtrl
ClientCtrl.DestroyListener
-
-
Constructor Summary
Constructors Constructor Description EmulatorClient(Emulator emulator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DesktopAgentconnect(String zulPath)connect to a zul file, you have to provide the path that relative to the resource root folderDesktopAgentconnectAsIncluded(String zulPath, Map<String,Object> args)connect to a zul file, you have to provide the path that relative to the resource root folder.DesktopAgentconnectWithContent(String content, String ext, ComponentAgent parent, Map<String,Object> args)Connect to a zul content or another language from a string.voiddestroy()destroy this client, it will also destory all un-destroyed desktops that is created by this clientvoiddestroy(DesktopAgent desktopAgent)voidflush(String desktopId)flush the queued AU update event including piggyback events.HttpURLConnectiongetConnection(String path, String method)get a connection with current session and cookie.StringgetCookie(String key)get value of cookie with specify name.Map<String,String>getCookies()get all cookies in an unmodifiable map.EchoEventModegetEchoEventMode()get the current echo event handling mode.MapmapsOf(Object... args)Returns a map containing the given mappings.InputStreamopenConnection(String path)open a connection with current session and cookie.voidpostPiggyback(String desktopId, String targetUUID, String command, Map<String,Object> data, boolean ignorable)post a piggyback asynchronous update event.voidpostUpdate(String desktopId, String targetUUID, String command, Map<String,Object> data, boolean ignorable)post an asynchronous update event.voidsetCookie(String key, String value)set cookie for the client, the cookie will be sent at every HTTP request.voidsetDestroyListener(ClientCtrl.DestroyListener l)voidsetEchoEventMode(EchoEventMode mode)change the echo event handling mode.
-
-
-
Constructor Detail
-
EmulatorClient
public EmulatorClient(Emulator emulator)
-
-
Method Detail
-
connectAsIncluded
public DesktopAgent connectAsIncluded(String zulPath, Map<String,Object> args)
Description copied from interface:Clientconnect to a zul file, you have to provide the path that relative to the resource root folder. You can pass arguments through a map into the specific zul file as including.- Specified by:
connectAsIncludedin interfaceClient- Parameters:
zulPath- the path of zul file.args- the arguments to pass.- Returns:
- desktop agent.
- See Also:
ZatsEnvironment.init(String)
-
connectWithContent
public DesktopAgent connectWithContent(String content, String ext, ComponentAgent parent, Map<String,Object> args)
Description copied from interface:ClientConnect to a zul content or another language from a string. You can pass arguments through a map into the specific zul content or another language.- Specified by:
connectWithContentin interfaceClient- Parameters:
content- the raw content of the page. It must be a XML and compliant to the page format (such as ZUL).parent- the parent component, or null if you want it to be a root component. If parent is null, the page is assumed to be the current page, which is determined by the execution context. In other words, the new component will be the root component of the current page if parent is null.- Returns:
- desktop agent.
- See Also:
Executions.createComponentsDirectly(String, String, org.zkoss.zk.ui.Component, Map)
-
connect
public DesktopAgent connect(String zulPath)
Description copied from interface:Clientconnect to a zul file, you have to provide the path that relative to the resource root folder- Specified by:
connectin interfaceClient- See Also:
ZatsEnvironment.init(String)
-
destroy
public void destroy()
Description copied from interface:Clientdestroy this client, it will also destory all un-destroyed desktops that is created by this client
-
destroy
public void destroy(DesktopAgent desktopAgent)
- Specified by:
destroyin interfaceClientCtrl
-
postUpdate
public void postUpdate(String desktopId, String targetUUID, String command, Map<String,Object> data, boolean ignorable)
Description copied from interface:ClientCtrlpost an asynchronous update event. It will be queued until invoke flush.- Specified by:
postUpdatein interfaceClientCtrl
-
postPiggyback
public void postPiggyback(String desktopId, String targetUUID, String command, Map<String,Object> data, boolean ignorable)
Description copied from interface:ClientCtrlpost a piggyback asynchronous update event. a piggyback event's order is after normal events. It will be queued until invoke flush.- Specified by:
postPiggybackin interfaceClientCtrl
-
flush
public void flush(String desktopId)
Description copied from interface:ClientCtrlflush the queued AU update event including piggyback events.- Specified by:
flushin interfaceClientCtrl
-
getConnection
public HttpURLConnection getConnection(String path, String method)
Description copied from interface:ClientCtrlget a connection with current session and cookie.- Specified by:
getConnectionin interfaceClientCtrl- Parameters:
path- connect to this pathmethod- HTTP method
-
openConnection
public InputStream openConnection(String path) throws IOException
Description copied from interface:ClientCtrlopen a connection with current session and cookie.- Specified by:
openConnectionin interfaceClientCtrl- Parameters:
path- connect to this path- Throws:
IOException
-
setDestroyListener
public void setDestroyListener(ClientCtrl.DestroyListener l)
- Specified by:
setDestroyListenerin interfaceClientCtrl
-
setCookie
public void setCookie(String key, String value)
Description copied from interface:Clientset cookie for the client, the cookie will be sent at every HTTP request. The cookie name can't start with '$'. Please refer to section 3.2.2 of RFC 2965. If the name existed, the origin value will be replaced.
-
getCookie
public String getCookie(String key)
Description copied from interface:Clientget value of cookie with specify name.
-
getCookies
public Map<String,String> getCookies()
Description copied from interface:Clientget all cookies in an unmodifiable map.- Specified by:
getCookiesin interfaceClient- Returns:
- the map contained cookies.
-
setEchoEventMode
public void setEchoEventMode(EchoEventMode mode)
Description copied from interface:Clientchange the echo event handling mode. the default mode is EchoEventMode.IMMEDIATE- Specified by:
setEchoEventModein interfaceClient- Parameters:
mode- Control echo event handling mode. If null, do nothing.- See Also:
EchoEventMode
-
getEchoEventMode
public EchoEventMode getEchoEventMode()
Description copied from interface:Clientget the current echo event handling mode. the default mode is EchoEventMode.IMMEDIATE- Specified by:
getEchoEventModein interfaceClient- Returns:
- current echo event handling mode.
- See Also:
EchoEventMode
-
-