public ActionResult Index(string productId, string socketId) { ActionResult result = null; bool bought = MvcApplication.ProductRepository.Buy(productId); var model = MvcApplication.ProductRepository.GetProductById(productId); if (bought) { ViewBag.Info = model.Title + " successfully bought"; var stockEvent = new StockUpdatedEvent(model, socketId); ObjectPusherRequest request = new ObjectPusherRequest("product-" + stockEvent.ProductId, "stockUpdated", stockEvent); _provider.Trigger(request); } else { ViewBag.Error = "There was a problem buying " + model.Title; } if (socketId != null) { result = GetBoughtStatusCode(bought); } else { result = View("Index", model); } return result; }
public void ProcessRequest() { var provider = new PusherProvider("18353", "272a4f27cd993f2801a9", "c846a22521b7ed4c7f83"); ObjectPusherRequest request = new ObjectPusherRequest("my-channel", "my-event", new { message = "hello world" }); provider.Trigger(request); }
public void NotifyHunterLeft(Hunter hunter) { var request = new ObjectPusherRequest(hunter.HuntInstance.Id.ToString("D"), EventTypes.HunterLeft.ToString(), new { id = hunter.Id.ToString("D"), name = hunter.Account.Name, profileImageUrl = hunter.Account.ProfileImageUrl }); _provider.Trigger(request); }
public ActionResult Index(string chatMessage, string username) { var now = DateTime.UtcNow; var request = new ObjectPusherRequest( "chat_channel", "message_received", new { message = chatMessage, user = username, timestamp = now.ToShortDateString() + " " + now.ToShortTimeString() }); Provider.Trigger(request); return View(); }
protected void Button2_Click(object sender, EventArgs e) { using (SqlConnection myConnection = new SqlConnection()) { myConnection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["WeatherDBConnectionString"].ConnectionString; SqlCommand myCommand = new SqlCommand(); myCommand.Connection = myConnection; myCommand.CommandText = "dbo.uspGetAllClients"; myCommand.CommandType = CommandType.StoredProcedure; DataSet ds = new DataSet(); SqlDataAdapter daAdapter = new SqlDataAdapter(); daAdapter.SelectCommand = myCommand; daAdapter.Fill(ds); var provider = new PusherProvider("18353", "272a4f27cd993f2801a9", "c846a22521b7ed4c7f83"); foreach (DataRow DR in ds.Tables[0].Rows) { string value1; string value2; value1 = DR[0].ToString().Trim(); value2 = DR[1].ToString().Trim(); WeatherBug wb = new WeatherBug(); WeatherInfo wi = wb.checkWeather(value1, value2); Label1.Text = wi.humidity; ObjectPusherRequest request = null; String channel; if (value1 == "0") { channel = "CITY" + value2; request = new ObjectPusherRequest(channel, "my-event", wi); } else if (value1 == "1") { channel = "ZIP" + value2; request = new ObjectPusherRequest(channel, "my-event", wi); } provider.Trigger(request); Literal1.Text += value1 + value2 + "<br />"; } GridView1.DataSource = ds; GridView1.DataBind(); } }
public ActionResult PrivateMessage(string chatMessage, string username,string ChannelName) { var now = DateTime.UtcNow; ObjectPusherRequest request = new ObjectPusherRequest( ChannelName, "message_received", new { message = chatMessage, user = username, timestamp = now.ToShortDateString() + " " + now.ToShortTimeString() }); // var socketID =HttpContext.Request["socket_id"].ToString(); // Provider.Authenticate("presence-channel",request.SocketId.ToString()); Provider.Trigger(request); return View(); }
public void DoWork() { using (SqlConnection myConnection = new SqlConnection()) { myConnection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["WeatherDBConnectionString"].ConnectionString; SqlCommand myCommand = new SqlCommand(); myCommand.Connection = myConnection; myCommand.CommandText = "dbo.uspGetAllClients"; myCommand.CommandType = CommandType.StoredProcedure; DataSet ds = new DataSet(); SqlDataAdapter daAdapter = new SqlDataAdapter(); daAdapter.SelectCommand = myCommand; daAdapter.Fill(ds); foreach (DataRow DR in ds.Tables[0].Rows) { string value1; string value2; value1 = DR[0].ToString().Trim(); value2 = DR[1].ToString().Trim(); WeatherBug wb = new WeatherBug(); WeatherInfo wi = wb.checkWeather(value1, value2); ObjectPusherRequest request = null; String channel; var provider = new PusherProvider("18353", "272a4f27cd993f2801a9", "c846a22521b7ed4c7f83"); if (value1 == "0") { channel = "CITY" + value2; request = new ObjectPusherRequest(channel, "my-event", wi); } else if (value1 == "1") { channel = "ZIP" + value2; request = new ObjectPusherRequest(channel, "my-event", wi); } provider.Trigger(request); } } }
public void NotifyObjectiveFound(FoundObjective objective) { var request = new ObjectPusherRequest( objective.Hunter.HuntInstance.Id.ToString("D") + "_" + objective.Hunter.HuntInstance.Admin.Id.ToString("D"), EventTypes.ObjectiveFound.ToString(), new { hunter = new { id = objective.Hunter.Id.ToString("D"), name = objective.Hunter.Account.Name, profileImageUrl = objective.Hunter.Account.ProfileImageUrl }, objective = new { id = objective.Objective.Id.ToString("D"), name = objective.Objective.Name, imgUrl = objective.ImageUrl } }); _provider.Trigger(request); }
protected void Button3_Click(object sender, EventArgs e) { WeatherBug wb = new WeatherBug(); WeatherInfo wi = wb.checkWeather("0", "70577"); Label1.Text = wi.humidity; var provider = new PusherProvider("18353", "272a4f27cd993f2801a9", "c846a22521b7ed4c7f83"); ObjectPusherRequest request = new ObjectPusherRequest("my-channel", "my-event", wi); provider.Trigger(request); }
private int ProcessRecords(string fullPath) { List<string> records = new List<string>(); int count = 0; try { try { // Attempt to open the file exclusively. using (FileStream fs = File.Open(fullPath, FileMode.Open, FileAccess.ReadWrite, FileShare.None)) { string line; StreamReader sr = new StreamReader(fs); while ((line = sr.ReadLine()) != null) { records.Add(line); } fs.SetLength(0L); sr.Close(); } } catch (IOException ioe) { throw ioe; } // If we got this far send the data if (records.Count > 0) { ExperimentStorageProxy essProxy = new ExperimentStorageProxy(); essProxy.OperationAuthHeaderValue = new OperationAuthHeader(); essProxy.OperationAuthHeaderValue.coupon = opCoupon; essProxy.Url = essUrl; //replace DataSocket code with 'Pusher' interface IPusherProvider provider = new PusherProvider(pusherID, pusherKey, pusherSS, null); foreach (string rec in records) { string[] vals = rec.Split(delim, 2); DateTime timeStamp = new DateTime(0L, DateTimeKind.Local); bool status = DateTime.TryParseExact(vals[0].Replace("\"", ""), "yyyy-MM-dd HH:mm:ss", null, DateTimeStyles.None, out timeStamp); string record = "\"" + timeStamp.ToString("o") + "\"," + vals[1]; try { essProxy.AddRecord(experimentID, submitter, recordType, false, record, null); } catch (Exception essEx) { Logger.WriteLine("BeeEventHandler: OnChange ESS: " + essEx.Message); } try { string str = @"{'rawData': [" + record + "]}"; ObjectPusherRequest request = new ObjectPusherRequest(pusherChannel, "meassurement-added", str); provider.Trigger(request); } catch (Exception dsEx) { Logger.WriteLine("BeeEventHandler: OnChange DS: " + dsEx.Message); } count++; } //Pusher interface Close not needed } } catch (Exception e) { } return count; }
public void JudgingReady(Guid roundId, Player judge, Player[] players) { var data = new RoundStart { round_id = roundId, players = players }; var request = new ObjectPusherRequest( judge.private_channel, "game-judging-ready", data); server.Trigger(request); }
public void JudgingComplete(Guid roundId, Player winner, string actualSearch) { var data = new RoundWinner { round_id = roundId, winning_player = (winner != null) ? winner.name : null, actual_search = actualSearch }; var request = new ObjectPusherRequest( PUBLIC_CHANNEL, "game-judging-completed", data); server.Trigger(request); }
private void OnMemberAdded(object data) { try { var clientData = data.ToObject<ClientData>(); Channel privateChannel = client.Subscribe(clientData.info.private_channel); privateChannel.Bind( "client-guess-submitted", a => { try { var triggerData = a.ToObject<SubmittedGuess>(); var request = new ObjectPusherRequest(PUBLIC_CHANNEL, "game-guess-submitted", triggerData); server.Trigger(request); if (GuessSubmitted != null) GuessSubmitted(this, new GuessSubmittedEventArgs(a)); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }); privateChannel.Bind( "client-judging-submitted", b => { try { var triggerData = b.ToObject<JudgingSubmitted>(); var request = new ObjectPusherRequest(PUBLIC_CHANNEL, "game-judging-submitted", triggerData); server.Trigger(request); if (JudgeSubmitted != null) JudgeSubmitted(this, new JudgingCompleteEventArgs(b)); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }); if (PlayerJoined != null) PlayerJoined(this, new ClientEventArgs(data)); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
public void RoundStarted(Guid roundId, string imageUrl, Player[] players) { var data = new RoundStart { round_id = roundId, image_url = imageUrl, players = players }; var request = new ObjectPusherRequest( PUBLIC_CHANNEL, "game-round-started", data); server.Trigger(request); }
public void ResetGame(Guid roundId) { var request = new ObjectPusherRequest(PUBLIC_CHANNEL, "game-round-reset", new {round_id = roundId}); this.server.Trigger(request); }