This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.SignalR; | |
using WebAPI.Helpers.Models; | |
public class ChatHub : Hub | |
{ | |
[HubMethodName("SendMessageToAll")] | |
public async Task SendMessage(ChatMessage message) | |
{ | |
await Clients.All.SendAsync("ReceiveMessage", message); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ChatMessage | |
{ | |
public string User { get; set; } | |
public string Message { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.UseEndpoints(endpoints => | |
{ | |
endpoints.MapControllers(); | |
endpoints.MapHub<ChatHub>("/hubs/chat"); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services.AddCors(options => | |
{ | |
options.AddPolicy("ClientPermission", policy => | |
{ | |
policy.AllowAnyHeader() | |
.AllowAnyMethod() | |
.WithOrigins("http://localhost:3000") | |
.AllowCredentials(); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.UseCors("ClientPermission"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services.AddSignalR(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "bootstrap/dist/css/bootstrap.min.css"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useEffect, useRef } from "react"; | |
import { HubConnectionBuilder } from "@microsoft/signalr"; | |
import ChatWindow from "./ChatWindow"; | |
import ChatInput from "./ChatInput"; | |
import { Container } from "reactstrap"; | |
const Chat = () => { | |
const [connection, setConnection] = useState(null); | |
const [chat, setChat] = useState([]); | |
const latestChat = useRef(null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function scrapePrice(url){ | |
const browser = await puppeteer.launch(); | |
const page = await browser.newPage(); | |
await page.goto(url); | |
const [el] = await page.$x('<XPath>'); | |
const txt = await (await el.getProperty('textContent')).jsonValue(); // return 9,71 but parseFloat need to period not comma | |
browser.close(); | |
let stringTxt = JSON.stringify(txt).replace('"',"").replace('"',"").replace(",","."); // first change json to string type, this return "number.decimal" and some string methods | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let puppeteer = require('puppeteer'); | |
var nodemailer = require('nodemailer'); | |
scrapePrice('https://www.google.com/search?client=opera&hs=Wzk&sxsrf=ALeKk00I7IW96h0D13mdL99WUos0Xhz5MA%3A1604829566135&ei=fsGnX_DmB4XosAeQpInwAQ&q=türk+hava+yolları+hisse&oq=türk+hava+yolları+hisse&gs_lcp=CgZwc3ktYWIQAzIICAAQyQMQywEyBQgAEMsBMgUIABDLATIFCAAQywEyBQgAEMsBMgUIABDLATIFCAAQywEyBQgAEMsBMgUIABDLATIFCAAQywE6BAgAEEc6CwguEMcBEK8BEMsBUMULWKYSYNcSaABwAngAgAGpAogBwAeSAQUwLjQuMZgBAKABAaoBB2d3cy13aXrIAQjAAQE&sclient=psy-ab&ved=0ahUKEwjwnduB2PLsAhUFNOwKHRBSAh4Q4dUDCAw&uact=5'); | |
function main(srcTxt) | |
{ | |
let currentPrice = srcTxt; | |
let myPrice = 9.62; |
OlderNewer