private void testConnection(string module, string[] args) { Dictionary <string, string> d = new Dictionary <string, string>(); d.Add("method", "checkStatus"); bool status = false; try { Dictionary <string, string> response = CommunicationHelpers.DoRequest(gatewayURL, d); if (response.ContainsKey("status") && response["status"] == "INSOMNIA") { status = true; } } catch (Exception e) { m_log.ErrorFormat("[OMECONOMY] - Exception: {0}", e.Message); } m_log.Info("[OMECONOMY]: +---------------------------------------"); m_log.Info("[OMECONOMY]: | gridID: " + gridURL); m_log.Info("[OMECONOMY]: | connectionStatus: " + status); m_log.Info("[OMECONOMY]: +---------------------------------------"); }
private void registerModule(string module, string[] args) { m_log.Info("[OMECONOMY]: +-"); m_log.Info("[OMECONOMY]: | Your grid identifier is \"" + gridURL + "\""); String shortName = MainConsole.Instance.CmdPrompt(" [OMECONOMY]: | Please enter the grid's nick name"); String longName = MainConsole.Instance.CmdPrompt(" [OMECONOMY]: | Please enter the grid's full name"); Dictionary <string, string> d = new Dictionary <string, string>(); d.Add("method", "registerScript"); d.Add("gridShortName", shortName); d.Add("gridLongName", longName); d.Add("gridDescription", ""); d.Add("gridURL", gridURL); Dictionary <string, string> response = CommunicationHelpers.DoRequest(gatewayURL, d); if (response.ContainsKey("success") && response["success"] == "TRUE") { m_log.Info("[OMECONOMY]: +-"); m_log.Info("[OMECONOMY]: | Please visit"); m_log.Info("[OMECONOMY]: | " + response["scriptURL"]); m_log.Info("[OMECONOMY]: | to get the Terminal's script"); m_log.Info("[OMECONOMY]: +-"); } else { m_log.Error("[OMECONOMY]: Could not active the grid. Please check the parameters and try again"); } }
private void InitializeRegion() { regionSecret = null; Dictionary <string, string> d = new Dictionary <string, string>(); d.Add("method", "initializeRegion"); d.Add("regionIP", regionAddress); d.Add("regionName", regionName); d.Add("regionUUID", regionUUID.ToString()); d.Add("gridURL", gridURL); d.Add("gridShortName", gridShortName); d.Add("simulatorVersion", VersionInfo.Version); d.Add("moduleVersion", MODULE_VERSION); Dictionary <string, string> response = CommunicationHelpers.DoRequest(gatewayURL, d); if (response == null) { m_log.Error("[OMECONOMY]: error reading region secret"); } else { regionSecret = response["regionSecret"]; m_log.Info("[OMECONOMY]: region initialized successfully"); } }
public static string GetGatewayURL(string initURL, string name, string moduleVersion, string gatewayEnvironment) { #region // Debug #if DEBUG m_log.DebugFormat("[OMECONOMY] getGatewayURL({0}, {1}, {2}, {3})", initURL, name, moduleVersion, gatewayEnvironment); #endif #endregion Dictionary <string, string> d = new Dictionary <string, string>(); d.Add("moduleName", name); d.Add("moduleVersion", moduleVersion); d.Add("gatewayEnvironment", gatewayEnvironment); Dictionary <string, string> response = CommunicationHelpers.DoRequest(initURL, d); string gatewayURL = (string)response["gatewayURL"]; if (gatewayURL != null) { m_log.InfoFormat("[OMECONOMY]: GatewayURL: {1}", name, gatewayURL); } else { m_log.ErrorFormat("[OMECONOMY]: Could not set the GatewayURL - Please restart or contact the module vendor", name); } return(gatewayURL); }
/** * @brief Runs in a worker thread to tell money server the avatar is present in this region. * * <we send a claimUser message to server> * method=claimUser * avatarUUID=e8b4d660-8ef2-49e0-a202-3d1f8f06c2db * avatarName=Kunta Kinte * language=ENG * viewer=Imprudence 1.3.2.0 * clientIP=http://173.166.90.236:58410/ * regionUUID=c1d50d10-7117-1ff1-b0c4-0800200c9a66 * gridURL=http://world.dreamnation.net:8003/ * gridShortName=dreamnation * regionIP=http://69.25.198.248:9900/ * <server sends us a genericNotify callback> * method notifyIsAlive * avatarUUID e8b4d660-8ef2-49e0-a202-3d1f8f06c2db * regionUUID c1d50d10-7117-1ff1-b0c4-0800200c9a66 * notificationID 3714625 * nonce 370619060 * <we send a ValidatRequest message for the genericNotify> * method=verifyNotification * notificationID=3714601 * regionUUID=c1d50d10-7117-1ff1-b0c4-0800200c9a66 * hashValue=dbfe314d251daf47df4341f3942e4f4ad99c14af * <server replies to the ValidateRequest> * {'status' : 'OK'} * <server sends us a currencyNotify callback> * method notifyBalanceUpdate * avatarUUID e8b4d660-8ef2-49e0-a202-3d1f8f06c2db * balance 3677 * regionUUID c1d50d10-7117-1ff1-b0c4-0800200c9a66 * notificationID 3714603 * nonce 3861607714 * <we send a ValidatRequest message for the currencyNotify> * method=verifyNotification * notificationID=3714603 * regionUUID=c1d50d10-7117-1ff1-b0c4-0800200c9a66 * hashValue=fa1bd60a548649f0a238231f515b01cb14992711 * <server replies to the ValidateRequest> * {'status' : 'OK'} * <server replies to the claimUser message> * {"success":"true"} * * Notes: * 1) the server occasionally replies 'NOK' to our ValidateRequest messages. * 2) even when it returns 'NOK' to the ValidateRequest messages, the dumbbell * server replies {"success":"true"} to the original claimUser message. */ private void asynchronousClaimUser(String gatewayURL, Dictionary <string, string> data) { if (CommunicationHelpers.DoRequest(gatewayURL, data) == null) { String message = "The currency service is not available. Please try again later."; SceneHandler.Instance.LocateClientObject(new UUID(data["avatarUUID"])).SendBlueBoxMessage(UUID.Zero, String.Empty, message); } }
public void Close() { if (Enabled) { List <string> regions = SceneHandler.Instance.GetUniqueRegions().ConvertAll <String>(UUIDToString); Dictionary <string, string> d = new Dictionary <string, string>(); d.Add("method", "closeRegion"); d.Add("gridURL", gridURL); d.Add("gridShortName", gridShortName); d.Add("regions", JsonMapper.ToJson(regions)); CommunicationHelpers.DoRequest(gatewayURL, d); regionSecret = null; } }
private void OnClientClosed(UUID clientID, Scene scene) { Scene sc = SceneHandler.Instance.LocateSceneClientIn(clientID); if (sc == null) { return; } try { Dictionary <string, string> d = new Dictionary <string, string>(); d.Add("method", "leaveUser"); d.Add("avatarUUID", clientID.ToString()); d.Add("regionUUID", sc.RegionInfo.RegionID.ToString()); CommunicationHelpers.DoRequest(gatewayURL, d); } catch (Exception e) { m_log.DebugFormat("[OMECONOMY]: LeaveAvatar(): {0}", e.Message); } }
private Hashtable userInteract(Hashtable requestData) { Hashtable rparms = new Hashtable(); try { UUID receiverUUID = UUID.Parse((string)requestData["receiverUUID"]); Int32 type = Int32.Parse((string)requestData["type"]); String payloadID = (string)requestData["payloadID"]; Dictionary <string, string> d = new Dictionary <string, string>(); d.Add("method", "getNotificationMessage"); d.Add("payloadID", payloadID); Dictionary <string, string> messageItems = CommunicationHelpers.DoRequest(gatewayURL, d); if (messageItems == null) { throw new Exception("Could not fetch payload with ID " + payloadID); } m_log.Debug("[OMECONOMY] userInteract*:"); foreach (KeyValuePair <string, string> pair in messageItems) { m_log.Debug("[OMECONOMY] " + pair.Key + " " + pair.Value); } IClientAPI client = SceneHandler.Instance.LocateClientObject(receiverUUID); if (client == null) { throw new Exception("Could not locate the specified avatar"); } Scene userScene = SceneHandler.Instance.GetSceneByUUID(client.Scene.RegionInfo.originRegionID); if (userScene == null) { throw new Exception("Could not locate the specified scene"); } String message = messageItems["message"]; UUID senderUUID = UUID.Zero; String senderName = String.Empty; IDialogModule dm = null; IClientAPI sender = null; IUserManagement userManager = SceneHandler.Instance.GetRandomScene().RequestModuleInterface <IUserManagement>(); if (userManager == null) { throw new Exception("Could not locate UserMangement Interface"); } switch (type) { case (int)NotificationType.LOAD_URL: String url = messageItems["url"]; dm = userScene.RequestModuleInterface <IDialogModule>(); dm.SendUrlToUser(receiverUUID, "OMEconomy", UUID.Zero, UUID.Zero, false, message, url); break; case (int)NotificationType.CHAT_MESSAGE: senderUUID = UUID.Parse(messageItems["senderUUID"]); senderName = userManager.GetUserName(senderUUID); client.SendChatMessage( message, (byte)ChatTypeEnum.Say, Vector3.Zero, senderName, senderUUID, senderUUID, (byte)ChatSourceType.Agent, (byte)ChatAudibleLevel.Fully); sender = SceneHandler.Instance.LocateClientObject(senderUUID); if (sender != null) { sender.SendChatMessage( message, (byte)ChatTypeEnum.Say, Vector3.Zero, senderName, senderUUID, senderUUID, (byte)ChatSourceType.Agent, (byte)ChatAudibleLevel.Fully); } break; case (int)NotificationType.ALERT: dm = userScene.RequestModuleInterface <IDialogModule>(); dm.SendAlertToUser(receiverUUID, message); break; case (int)NotificationType.DIALOG: client.SendBlueBoxMessage(UUID.Zero, "", message); break; case (int)NotificationType.GIVE_NOTECARD: break; case (int)NotificationType.INSTANT_MESSAGE: senderUUID = UUID.Parse(messageItems["senderUUID"]); UUID sessionUUID = UUID.Parse(messageItems["sessionUUID"]); if (messageItems.ContainsKey("senderName")) { senderName = messageItems["senderName"]; } else { senderName = userManager.GetUserName(UUID.Parse((string)messageItems["senderUUID"])); } GridInstantMessage msg = new GridInstantMessage(); msg.fromAgentID = senderUUID.Guid; msg.toAgentID = receiverUUID.Guid; msg.imSessionID = sessionUUID.Guid; msg.fromAgentName = senderName; msg.message = (message != null && message.Length > 1024) ? msg.message = message.Substring(0, 1024) : message; msg.dialog = (byte)InstantMessageDialog.MessageFromAgent; msg.fromGroup = false; msg.offline = (byte)0; msg.ParentEstateID = 0; msg.Position = Vector3.Zero; msg.RegionID = userScene.RegionInfo.RegionID.Guid; client.SendInstantMessage(msg); sender = SceneHandler.Instance.LocateClientObject(senderUUID); if (sender != null) { sender.SendInstantMessage(msg); } break; default: break; } rparms["success"] = true; } catch (Exception e) { m_log.ErrorFormat("[OMECONOMY]: userInteract() Exception: {1} - {2}", Name, e.Message, e.StackTrace); rparms["success"] = false; } return(rparms); }